Today I have learned that evt.dataTransfer.files are not Arrays , they are Objects
And to iterate through them you must call
Array.prototype.forEach
So I was doing my homework today and to my suprise , I got an error iterating over evt.dataTransfer.files . Like what in the world is going on . Turns out , its not an array its an Object . TO iterate through them you must use Array.prototype.forEach.call . Good thing Ive watched the
TutsPlus - JavaScript Fundamentals 101 . A life saver ,.
dropContainer.addEventListener('drop',function(evt){
evt.stopPropagation();
evt.preventDefault();
Array.prototype.forEach.call(evt.dataTransfer.files, function (currentData) {
alert(currentData.name);
});
filereader = new FileReader;
filereader.onload = function(){
}
//read the files
// prepare ajax content
});
No comments:
Post a Comment