reader.onload =函数(e)未执行javascript

时间:2019-09-24 08:36:59

标签: javascript filereader

我正在尝试将文件上传到共享点列表项。问题是,每当我调用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); 


 }

0 个答案:

没有答案