I recently implemented a similar task that you are trying to achieve using similar resources. You did not indicate that you need audio downloaded as mp3, so I will just show you how to download wav using recorderjs using the source found here: https://github.com/cwilso/AudioRecorder
First of all, recordings store uncompressed wav in a var called blob. This happens on line 101 of the js recorder, more specifically in this function:
worker.onmessage = function(e){ var blob = e.data; currCallback(blob); }
The problem is that blob is locally declared in this function. We need to use it again, so for this example, let's make it very easy to achieve and make it global. Therefore, declare the blob variable outside the js logger as follows:
var blob = null;
Then change the above function in recorderjs to save the data inside the globally declared blob variable, the function should look like this:
worker.onmessage = function(e){ blob = e.data; currCallback(blob); }
Now we can use the "blob". Now declare the following function,
function uploadAudio(){ var fd = new FormData(); var wavName = encodeURIComponent('audio_recording_' + new Date().getTime() + '.wav'); console.log("wavName = " + wavName); fd.append('fname', wavName); fd.append('data', blob); $.ajax({ type: 'POST', url: 'upload.php', data: fd, processData: false, contentType: false }).done(function(data) {
Your server side code should use this:
<?php if(!is_dir("recordings")){ $res = mkdir("recordings",0777); } move_uploaded_file($_FILES["file"]["tmp_name"], $res . $_FILES["file"]["fname"]); ?>
Note: $ _FILES ["file"] ["tmp_name"] is what it looks like. Temporary file location. This is done for you with ajax call and form data.
Good luck, let me know if you have any problems.