I have studied many articles and posts to learn about File API and still don't understand why almost all of them use event.target instead of reader. Here are three examples:
- File API
- https://developer.mozilla.org/en-US/...elected_images
- Working with files in JavaScript, Part 2: FileReader | NCZOnline
The last reference even recommends using event.target:
But why is it recommended and widely used? What's wrong with using reader or simpler this instead: DEMO.The FileReader instance is available inside of the event handler via event.target and it’s recommended to use that instead of referencing the reader variable directly.
I know this and event.target can be different, but in this case they both refer to the FileReader object.
- reader: an instance of FileReader;
- onload: a FileReader event;
- result: a FileReader property;
While you can use reader.onload, then why not reader.result?



Reply With Quote

Bookmarks