Hi, I want to save the path of the audio file to the database and the audio file to my download folder, here is my code: -
<a class="btn btn-large btn-danger" id="ahref" target="_blank" onclick="$('#audioLayerControl')[0].save($('#ahref')[0]);"><i class="icon-fire"></i> save</a>
When I clicked on this link, my audio recording recorded by me will be saved in the downloads folder and I can play it, but I want to save it in my uploads folder. I get a blob url like this blob:http%3A//localhost%3A8383/0dd9e04b-d6db-4c8c-94b5-51cfb619f725, here is its script: -
this.save = function save(saveLink)
{
var url = this.toWave().toBlobUrlAsync("application/octet-stream");
document.getElementById("ahref").src=url;
var final=document.getElementById("ahref").download = new Date().toISOString() + '.wav';
};
Thanks, please help me.
Updated After Using Ajax
var blobUrl=url;
var xhr = new XMLHttpRequest;
xhr.responseType = 'blob';
xhr.onload = function() {
var recoveredBlob = xhr.response;
var reader = new FileReader;
reader.onload = function() {
var blobAsDataUrl = reader.result;
window.location = blobAsDataUrl;
};
reader.readAsDataURL(recoveredBlob);
};
xhr.open('POST', 'upload.php', true);
xhr.send(blobUrl);
upload.php
<?php
error_reporting(0);
if( isset($HTTP_RAW_POST_DATA))
{
echo $cad = $HTTP_RAW_POST_DATA;
}
?>
Ouput: - blob:http%3A//localhost%3A8383/5155c610-dec6-4e60-8ef7-e14a56aa73d2
and in the browser url data:text/html;base64,YmxvYjpodHRwJTNBLy9sb2NhbGhvc3QlM0E4MzgzLzUxNTVjNjEwLWRlYzYtNGU2MC04ZWY3LWUxNGE1NmFhNzNkMg==
source
share