如何从' blob创建文件:http://'网址

时间:2017-06-07 09:45:21

标签: php fopen file-get-contents file-put-contents

我有blob:http://unifiedmain.localhost.com/a4580f39-8f9d-4e8c-8e4b-02a6bd2df3df个网址,我想从中创建实际的文件。

我已经习惯了 PHP代码:

file_put_contents('E:\www\nginx\html\unifinedmainsite\123.mp3', file_get_contents($_REQUEST['id']));.

javascript代码:

var xhr = new XMLHttpRequest;
xhr.responseType = 'blob';

xhr.onload = function() {
var recoveredBlob = xhr.response;

var reader = new FileReader;

reader.onload = function() {
jQuery.ajax({
        type: "POST",
        url: BASEURL+"/index.php?saveFileInSession=true",
        data: "id="+reader.result,
        success: function(response) {
            console.log(response);
        }
    });

 };

reader.readAsDataURL(recoveredBlob);
};

xhr.open('GET', 'blob:http://unifiedmain.localhost.com/a4580f39-8f9d-4e8c-8e4b-02a6bd2df3df');
xhr.send();

文件正在生成实际大小,但我无法打开它,我做错了什么?

我是否必须传递一些标题或其他内容?以便我可以播放保存/上传的.mp3文件?

请帮忙。

0 个答案:

没有答案