Why is not working on onload FileReader?

There is code:
var file;
 var reader = new FileReader();
 var dropZone = document.getElementById('drop_zone');
 function handleFileSelect(evt) {
 file = evt.dataTransfer.files[0];
evt.the stoppropagation();
evt.preventDefault();
 reader.onload = function(e) {
console.log('1');
console.log(reader.readAsText(file));
console.log(this.result);
};
};
 function handleDragOver(evt) {
evt.the stoppropagation();
evt.preventDefault();
};
 dropZone.addEventListener('dragover', handleDragOver, false);
 dropZone.addEventListener('drop', handleFileSelect, false);


And the part where render.onload = f does not work, although the fact that it works just fine. Demo, in console type "showPopup('file_set')" drag in the white area any. txt file.
June 14th 19 at 20:19
1 answer
June 14th 19 at 20:21
Solution
Does not work because you did not load - you are trying to read a file in the onload handler. Naturally, nothing happens. Do this:
reader.onload = function(e) {
console.log(this.result);
};
reader.readAsText(file);
Works, thank you! - Skye.Fries commented on June 14th 19 at 20:24

Find more questions by tags JavaScript