1
I created one and would like to read the contents of that input before sending it to the server. I saw that I can do this using a filereader but the information I found was a bit confusing.
How can I do this reading?
The reading would be from a txt file.
var file = document.getElementById("inputmarc");
var fr = new FileReader();
fr.readAsBinaryString(file.files[0]);
fr.onload = function(e) { alert(e); }
In HTML:
<input type="file" id="inputmarc">
Is there any way to put in the code you tried to do? Taking advantage, you can also put an example of what you want to do, such as the format of the file that will be read and what content you expect to read in that file.
– Woss
I don’t think I can edit a question yet, it’s a txt file.
var file = document.getElementById("inputmarc");

 var fr = new FileReader();
 fr.readAsBinaryString(file.files[0]);
 fr.onload = function(e)
 {
 alert(e);
 }
– Andre Alvim
And the HTML code?
– Woss
It’s just a <input type="file" id="inputmarc">
– Andre Alvim