If I upload data (say a text file) from my local computer, with this function
var button = document.getElementById('myFile');
<p id = "out">The content of the file is</p>
<input type = "file" id = "myFile" style="margin-top:5%;">
How do I retrieve data from the uploaded file? I'm thinking about the simplest case which can be a text file to be appended to a div.
FileReaderthat allows the browser to parse uploaded files. However, sometimes it might not be a good idea to read the entire file into memory—if it's too large you'll risk crashing the browser due to memory overflow.FileReaderFileReaderis sufficient. Also, the case is different if OP wants to parse other kinds of files.