RecortRTC save on server

Hi folks pls could you help I spend whole day trying to figure this out but no joy!

Trying to save get blob url and save it on server as mp3.

btnDownloadRecording.onclick = function() {
    this.disabled = true;
    if(!recorder || !recorder.getBlob()) return;



    var blob = recorder.getBlob();
    var file = new File([blob], getFileName('mp3'), {
        type: 'audio/mp3'
    });
    
	
// here
var http = new XMLHttpRequest();
var url = audioMessageUploader;

    var fd = new FormData();
	
	
    fd.append("audio-data", blob, file);
	


	
   http.open('POST', url, true);
	
	//Send the proper header information along with the request
    //http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	
    //Call a function when the state changes.
    http.onload=function(e) {
		      if(this.readyState === 4) {
		          console.log("Server returned: ",e.target.responseText);
		      }
             };
	//http.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    http.send(fd);
	// here
	
};

Hi @letsforum, from a quick look: you’re setting the file type to audio/mp3 which should probably be audio/webm instead, but to be safe you can get the type directly from the blob like { type: blob.type }. Furthermore, you’re passing the file object to fd.append() as the 3rd argument which should actually only be the name of the file, i.e. a string (probably the result of your getFileName() function, or just file.name for that matter).

Other than that, there are too many parts of your code missing to reproduce the problem… what are the exact errors you’re getting though (in the browser console and / or from your server)?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.