开发者

Converting a BlobBuilder to string, in HTML5 Javascript

开发者 https://www.devze.com 2023-03-24 16:36 出处:网络
function blobToString(blob) { var reader = new FileReader(); var d = \"\"; reader.onloadend = function() {
          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 som开发者_StackOverflowe binary data(WebKitBlobBuilder) to a string. Also the "console.log(reader.result);" doesn't display anything.


Check out http://blog.ericzhang.com/state-of-binary-in-the-browser/ and his binary.js project.


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

or try

reader.onload = function (e) {
e.target.result -> this is the data. 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消