I create a file at the client (record) and then I'd send it on my remote server. However I can not find how to do it without using an input file, I have the file path but when I need to send it by ajax is not detected in $ _FILES side PHP. If I create a blob it works but the file does not match the recording.
Is it possible?
[UPDATE 1]
The file is a audio/mpeg, this file is created after an audio recording, where I get the location and I can play it again. I need to recover without the user clicks on a file input
HTML
<form enctype="multipart/form-data" id="form_message" method="POST">
<textarea name="message" id="message" value="" placeholder="Ecris quelque chose"></textarea>
<input type="submit" style="display:none;" value="Valider"/>
</form>
JS
fd = new FormData();
fd.append('audiofile', 'filepath.mp3');
// other data
function submit_form_message(fd){
$.ajax({
type: 'POST',
url: "url",
data: fd,
processData: false,
contentType: false,
success: function(data){}
});
}
PHP
if($_FILES['audiofile']['size'] !=0){
if ($_FILES['audiofile']['error'] == 0){
$extensions_valides = array('mp3' , 'wav');
if(in_array($_POST['extension'],$extensions_valides)){
$tmp_name = $_FILES["audiofile"]["tmp_name"];
$name_file = $notId.".".$_POST['extension'];
move_uploaded_file($tmp_name, $_SERVER['DOCUMENT_ROOT']."/Bell/sound/".$name_file);
}
}
}