我正在尝试将文件上传到共享点列表项。问题是,每当我调用reader.onload = function(e)时,都会出现异常。这是我的代码:
var element = document.getElementById("dev");
var file = element.files[0];
var parts = element.value.split("\\");
var fileName = parts[parts.length - 1];
readFile(file,element,fileName );
readFile函数:
function readFile(file,element,fileName ){
//Read File contents using file reader
var reader = new FileReader();
reader.onload = function(e) {
uploadFile(e.target.result, fileName);
}
reader.onerror = function(e)
{
alert(e.target.error);
}
reader.readAsArrayBuffer(file);
}