According to I make a website for chat and I want to send voice to communicate.
so I use this script from
This is javascript
[code]function createDownloadLink(blob) {
//name of .wav file to use during upload and download (without extendion)
var filename = new Date().toISOString();
console.log(‘bob = ‘ + typeof(blob));
console.log(‘file name = ‘ + typeof(filename));
var fd=new FormData();
fd.append(“audio_data”,blob, filename);
$.ajax({
url: “../func/upload.php”,
method: “POST”,
processData: false,
contentType: false,
data: fd,
enctype: ‘multipart/form-data’,
success: function (data) {
console.log(‘SUCCESS’ + data);
},
error: function (err) {
}
});
}
and this is server side PHP
[code]
//this will print out the received name, temp name, type, size, etc.
print_r($_FILES);
$input = str_replace(“:”,”_”,$_FILES[‘audio_data’][‘tmp_name’]); //get the temporary name that PHP gave to the uploaded file
$output = $_FILES[‘audio_data’][‘name’].”.wav”; //letting the client control the filename is a rather bad idea
//move the file from temp name to local folder using $output name
move_uploaded_file($input, $output);
This is the print output
[code]
Array
(
[audio_data] => Array
(
[name] => 2021-07-02T07:59:33.877Z
[type] => audio/wav
[tmp_name] => C:xampptmpphpF3C8.tmp
[error] => 0
[size] => 44
)
)
It seem no any error but I don’t find any file on the server.
Could you please kindly help me check?