When readAsText() function is completed the result is stored in .result
How do I see if the content of the file read are correct in .
This took me like 300 hours to figure out even after reading the documentation and examples online...
Here's some actual, working code:
let fileReader = new FileReader();
fileReader.onload = function(event) {
alert(fileReader.result);
};
inputElement.onchange = function(event) {
fileReader.readAsText(event.target.files[0]);
};
Also, FYI:
FileReader.onabort A handler for the
abortevent. This event is triggered each time the reading operation is aborted.FileReader.onerror A handler for the
errorevent. This event is triggered each time the reading operation encounter an error.FileReader.onload A handler for the
loadevent. This event is triggered each time the reading operation is successfully completed.