1

I have blob:http://unifiedmain.localhost.com/a4580f39-8f9d-4e8c-8e4b-02a6bd2df3df url and i want to create actual file file from this.

I've used PHP code :

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

javascript code:

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();

file is generating with actual size but i can not open it ,what is i am doing wrong?

Do i have to pass some header or something?so that i can play my saved/uploaded .mp3 file?

please help.

Archish
  • 850
  • 8
  • 32
  • Possible duplicate: https://stackoverflow.com/questions/14952052/convert-blob-url-to-normal-url/16179887 (question is Javascript, but the answer gives some generic background which is probably relevant here). – IMSoP Jun 07 '17 at 11:22
  • i've already use this but not working, file is generating with actual size but i can not open it – Archish Jun 07 '17 at 11:31
  • Then that sounds like a different question to the one you've asked: you've succeeded in downloading the data, but it's not in the form expected? I suggest you [edit] the question to show that attempt, rather than the one which got 0kb. – IMSoP Jun 07 '17 at 11:35
  • When you say you cannot open it, what are you trying to open it with? And when you say "actual" size, is it precisely the expected number of bytes? – IMSoP Jun 07 '17 at 13:38
  • yes when i say "actual" size, it is precisely the expected number of bytes. and i am trying to open it simply by double clicking on it, means i am opening it in media player. – Archish Jun 08 '17 at 04:48
  • Open the file in a text editor, and see if there's any PHP errors. – Shea Jun 08 '17 at 05:50
  • there is no error – Archish Jun 08 '17 at 08:03

0 Answers0