Skip to content Skip to sidebar Skip to footer

Problems With Html5 Filereader

I try to run the FileReader function in my project but it only works pas.Mon project works like so I list all files in a directory. It all works. But when I select a file in the li

Solution 1:

I think the problem is that your filename variable is set to:

filename = "~ / Downloads / snippets" + event.target.innerHTML;

...which is a String, rather than the object that's expected by the readAsText function on FileReader.

Try something like this instead:

var fileInputElement = document.getElementById("fileInputElement");
fr.readAsText(fileInputElement.files[0]);

Where "fileInputElement" is the ID of the HTML <input> element of type file.

This may not fit exactly with what you're doing, but it's not easy to tell without seeing more of your JavaScript and HTML.

Post a Comment for "Problems With Html5 Filereader"