function readSingleFile(evt) {
//Retrieve the first (and only!) File from the FileList object
var f = evt.target.files[0];
if (f) {
var r = new FileReader();
r.onload = function(e) {
var contents = e.target.result;
alert( "Got the file.n"
+"name: " + f.name + "n"
+"type: " + f.type + "n"
+"size: " + f.size + " bytesn"
+ "starts with: " + contents.substr(1, contents.indexOf("n"))
);
}
r.readAsText(f);
} else {
alert("Failed to load file");
}
}
function readFiles() {
// Get input element
myFileList = document.getElementById("fileButton");
//Retrieve the first (and only!) File from the FileList object
var file = myFileList.files[0];
if (file) {
// loop through files property, using length to get number of files chosen
for (var i = 0; i < myFileList.files.length; i++) {
// display them in the div
//document.getElementById("display").innerHTML += "<br/>" + myFileList.files[i].name ;
var file = myFileList.files[i];
alert(file.name);
alert(file.size);
var r = new FileReader();
r.onload = function() {
var contents = r.result;
console.log(r.result.substring(0, 200));
alert(r.result.substring(0, 200));
}
r.readAsText(file);
}
} else {
alert("Failed to load file");
}
}