jquery 怎么实现获取文件夹里的文件

如题所述

jquery中实现获取文件夹里的文件采用遍历的方法。
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
// Print the contents of the file
var span = document.createElement('span');
span.innerHTML = ['<p>',e.target.result,'</p>'].join('');
document.getElementById('list').insertBefore(span, null);
};
})(f);

// Read in the file
//reader.readAsDataText(f,UTF-8);
//reader.readAsDataURL(f);

reader.readAsText(f);
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答