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 list (my files are local), I end up with this error I do not understand:
Uncaught TypeError: Failed to execute 'readAsText' on 'FileReader': The argument is not a Blob.
Here is my code:
GetFileName function (fs) {
var target = event.target || event.srcElement;
var childs = target.parentNode.childNodes;
{for (i = 0; i ++; i <childs.length)
if (target == childs [i]) break;
}
console.log (i); // Index li
console.log (event.target.innerHTML); // li value
filename = "~ / Downloads / snippets" + event.target.innerHTML;
var fr = new FileReader ();
fr.onload = function (e) {
console.log (e.target.result);
};
fr.readAsText (filename);
}
Does anyone have an idea of what does not work?
Thank you in advance for your help!
filenameto it. It expects aBlobrepresentation of a file or aFileobject.