I am following Html5rocks tutorial
http://www.html5rocks.com/en/tutorials/file/dndfiles/
and I am trying to use readAsArrayBuffer instead of readAsBinaryString in slicing a file example (because I want to read gif header to find file resolution). But I am stuck because evt.target.result (while using readAsBinaryString it is a string)
any ideas?
EDIT : Code
reader.onloadend = function(evt)
{
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
document.getElementById('byte_content').textContent = evt.target.result;
console.log(evt.target.result.byteLenght)
document.getElementById('byte_range').textContent =
['Read bytes: ', start + 1, ' - ', stop + 1,
' of ', file.size, ' byte file'].join('');
}
};
if (file.webkitSlice) {
var blob = file.webkitSlice(start, stop + 1);
} else if (file.mozSlice) {
var blob = file.mozSlice(start, stop + 1);
}
reader.readAsArrayBuffer(blob);
}
so in Firefox 13 I get on screen : [object ArrayBuffer]
and on console log : undefined
while in Chromium 18 I get on console : Uncaught TypeError: Cannot read property 'byteLenght' of null
[object arrayBuffer]. Include your code in the question, including details about your browser and your expectations.byteLengthhas to be spelled withth, notht. Post a full demo using jsfiddle.net whihc shows your problem.