Reading & Processing Files with the JavaScript FileReader API

1 · · Jan. 23, 2020, midnight
Reading, writing and analyzing files is an essential component of software development. For security reasons, in JavaScript, we can’t directly access users’ files. If we had something like fs in Node.js, we could just steal documents from users! First, to get a file from a user, we need to use an input element: <input id="my-input" type="file" onChange="handleFileChange"> This tiny piece of code will allow our user to upload files from her machine. The handleFileChange function that we’ll creat...