Return FileReader.readAsArrayBuffer equal to zero

I follow the Html5rocks tutorial

http://www.html5rocks.com/en/tutorials/file/dndfiles/

and I'm trying to use readAsArrayBuffer instead of readAsBinaryString in the context of an example file (because I want to read the gif header to find the file resolution). But I am stuck because evt.target.result (when using readAsBinaryString this 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 the screen: [object ArrayBuffer]

and in console log: undefined

while in Chromium 18 I get the console: Uncaught TypeError: Cannot read the property 'byteLenght' null

+4
source share
1 answer

IN:

there is an input error:
 console.log(evt.target.result.byteLenght) 

byteLenght must be byteLength

+5
source

All Articles