Converting a BlobBuilder to string, in HTML5 Javas

2019-03-01 21:52发布

          function blobToString(blob) {
             var reader = new FileReader();
             var d = "";
             reader.onloadend = function() {
                 d.callback(reader.result); 
                 console.log(reader.result);
             };
             reader.readAsText(blob);  
             return d;
         };

The above code does not work, but I guess my intentions are clear, I want to convert some binary data(WebKitBlobBuilder) to a string. Also the "console.log(reader.result);" doesn't display anything.

2条回答
仙女界的扛把子
2楼-- · 2019-03-01 22:11

it should not be reader.onloadend but rather reader.onloaded

or try

reader.onload = function (e) {
e.target.result -> this is the data. 
}
查看更多
登录 后发表回答