mardi 27 mai 2014

Saving recorded WAV File with Recorder.JS to Server


Vote count:

0




down vote


I work with RecorderJS and try to post my record on server as jimiayler


I followed your instructions gave by Forest Ka but my audio blob doesn't seem to load with xhr because when I pass in PHP file, the variable $_FILES is an empty array


Javascript code



function upload(blob) {
var xhr=new XMLHttpRequest();
xhr.onload=function(e) {
if(this.readyState === 4) {
console.log("Server returned: ",e.target.responseText));
}
};
var fd=new FormData();
fd.append("that_random_filename.wav",blob);
xhr.open("POST","server/postWav.php",true);
xhr.send(fd);
}


PHP code in postWav.php



print_r($_FILES);

// get the temporary name that PHP gave to the uploaded file
$tmp_filename=$_FILES["that_random_filename.wav"]["tmp_name"];
// rename the temporary file (because PHP deletes the file as soon as it's done with it)
rename($tmp_filename,"uploaded_audio.wav");

chmod("uploaded_audio.wav",0777);


In Chrome terminal I see



Server returned: Array ( )


Do you have any suggestions ?



asked 41 secs ago






Aucun commentaire:

Enregistrer un commentaire