JS读取client端的文件的代码片段

时间:2023-03-09 09:29:34
JS读取client端的文件的代码片段

JS读取client端的文件内容的代码片段

if(window.FileReader){
var html5file = this.pipeDetailFileUpLoader._files[0];
var reader = new FileReader();
reader.onload = lang.hitch(this,function(f) {
console.log(f.target.result);
});
//reader.readAsDataURL(html5file);
reader.readAsText(html5file);
}else{
//var ForReading = 1, ForWriting = 2, ForAppending = 8;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.OpenTextFile(this.pipeDetailFileUpLoader._inputs[0].value, 1, -2);
console.log(a.ReadLine());
a.Close();
}