FileReader allows to read local file in Chrome.
function readMultipleFiles(evt) {
var files = evt.target.files;
if (files) {
for (var i = 0, f; f = files[i]; i++) {
var r = new FileReader();
r.onload = (function (f) {
return function (e) {
var contents = e.target.result;
document.getElementById("output").innerHTML = contents;
};
})(f);
r.readAsText(f);
}
} else {
alert("Failed to load files");
}
}
document.getElementById('fileinput').addEventListener('change', readMultipleFiles, false);
But this example does not work in Internet Explorer 9.
Does IE9 support File API?
If yes – what should I do to have ability to read local files in IE9?
No, it doesn’t.
Did you mean if no? If so then you could use an ActiveX or just inform the user that this feature of your website is not supported on his browser and allow him the possibility to upload the file to the server.