Koozali.org: home of the SME Server

File Upload - Feature Request

Offline richardsmith

  • *
  • 34
  • +0/-0
File Upload - Feature Request
« on: July 11, 2014, 10:46:43 AM »
Not sure if you take feature requests on here or not, but one of the main things that would make life a lot easier would be to add a file upload facility for MOH and Greetings as Elastix does.  I did have a fiddle with this about a year ago and managed to get as far as getting a basic php script to appear on a new tab.  Whilst it got as far as allowing me to select the file and said the file upload was completed it didn't actually save the wav file in the MOH folder.  Unfortunately I ran out of time and have since lost the files I created etc.

It seems that it should be a fairly straightforward to someone with better knowledge of PHP etc. than I do.

Thanks,

Richard

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: File Upload - Feature Request
« Reply #1 on: July 11, 2014, 03:07:58 PM »
Thanks for that

I'll put it on the list for consideration in a future release.

Best

S
 







 

Offline richardsmith

  • *
  • 34
  • +0/-0
Re: File Upload - Feature Request
« Reply #2 on: August 28, 2014, 12:09:23 PM »
Hi

I have had a bit of time to play with this and I have managed to get something half working.  I created another tab in the navigation.php which points to a file I called moh.php, this file contains a simple form that uses a php script in another file called upload.php (found this on the net). I can get it to save a file within the /opt/sark/www/ directory but can't get it to save to anywhere above this root directory for the web files. Is is just that I have the wrong string for the file location of the MOH folder or is there another technical reason that it won't allow me to do this? I am using the following path ../var/lib/asterisk/moh/

Sorry my knowledge of php and linux is pretty limited, I am just to trying to get this feature working for a client who want to be able to regularly add new MOH marketing messages through the web interface.

I'm thinking this would also be helpful in the long run to upload files for IVR greetings too.

Thanks,

Richard

Offline SARK devs

  • ****
  • 2,806
  • +1/-0
    • http://sarkpbx.com
Re: File Upload - Feature Request
« Reply #3 on: August 29, 2014, 11:10:36 PM »
In EL5/6 implementations the default moh is usually in /var/lib/asterisk/
In Wheezy it is in /usr/share/asterisk/

In either case, these directories are owned by root so no, you can't upload files directly to them from a web application, at least not without figuring out how to manage the privileges. However, there's nothing to stop you creating your own moh folder and putting it wherever you like (including www).   Look at the documentation for musiconhold.conf in the asterisk documentation.

Whatever you do, you'll need to figure out the format and sample rate of the uploaded file and, if necessary, re-sample it or it won't playback; asterisk is quite finicky when it comes to audio file formats and sample rates.  You can avoid some of that by insisting on mp3 files.  The asterisk documentation advises against it (see http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/additional_configuration_tasks-musiconhold-conf-file.html) but in practice, it seems to work OK.

Finally, you will need to reload moh after the change. This is known to be temperamental, sometimes even requiring a soft restart of asterisk itself.

All of these issues can be solved and automated (except maybe handling a restart).  As you say earlier, Elastix and many of the other freePBX derivatives have some form of upload capability for moh.  However, the main reason we haven't put anything into sail (at least for moh) is that I know how fragile the asterisk moh routines are and I know how easy it is to break them with bad sound files. If you do break them you'll likely need to stop and restart asterisk and I don't think your customer will thank you for that if it happens too often.  Any general uploader runs the risk of exposing the PBX to potentially unknown stuff being loaded and processed by the Asterisk mainline unless you impose some pretty funky data checking and security on the way in. 

Hope this helps.

Kind Regards

S