How to read local file in JS?
function jsReadFiles(files) {
if (files.length) {
var file = files[0];
var reader = new FileReader();
if (/text+/.test(file.type)){
reader.onload = function(){
$('body').append('<pre>' + this.result + '</pre>');
}
reader.readAsText(file);
}else if(/image+/.test(file.type)) {
reader.onload = function() {
$('body').append('<img src="' + this.result + '"/>');
}
reader.readAsDataURL(file);
}
}
}