我使用Fineuploader Promise运行md5检查提交回调以防止文件已经存在再次上传,它在Chrome中工作但不在IE11中。是不是IE错误或我做错了?我该如何解决?非常感谢。 这是脚本:
$("#uploader").fineUploader({
request: {
endpoint: 'home/upload'
},
multiple: true,
autoUpload: false,
debug: true,
chuncking: {
enabled:true
},
editFilename: {
enable: true
},
validation: {
sizeLimit: 1073741824
}
}).on({
"complete": function (event, id, fileName, responseJSON) {
if (responseJSON.success) {
alert("upload success");
}
},
"validate": function (event,data) {
},
"submit": function (event,id, fileName) {
var promise = new qq.Promise();
var file = $(this).fineUploader('getFile', id);
var freader = new FileReader();
validateMD5(file, freader,promise);
return promise;
},
"error": function (event, id, fileName, reason) {
alert(reason);
}
});
$("#uploadButton").click(function () {
$('#uploader').fineUploader('uploadStoredFiles');
});
function validateMD5(file, reader,promise) {
var blobSlice = File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice;
var spark = new SparkMD5();
var chunkSize = 2097152;
var chunks = Math.ceil(file.size / chunkSize);
var currentChunk = 0;
var start1 = 0;
var end1 = chunkSize >= file.size ? file.size : chunkSize;
reader.readAsBinaryString(blobSlice.call(file, start1, end1));
reader.onload = function (e) {
spark.appendBinary(e.target.result);
currentChunk++;
if (currentChunk < chunks) {
var start = currentChunk * chunkSize;
var end = start + chunkSize >= file.size ? file.size : start + chunkSize;
reader.readAsBinaryString(blobSlice.call(file, start, end));
} else {
var md5 = spark.end();
var r = checkMd5Onserver(md5);
if (r == true) {
promise.success();
} else {
promise.failure();
}
}
};
}
function checkMd5Onserver(md5) {
return false;//just for test
}
答案 0 :(得分:1)
在我的代码中,我使用FileReader.readAsBinaryString()方法读取文件,IE11不再支持它。 FileReader.readAsBinaryString function-- doesnt work on IE11和http://www.w3.org/TR/FileAPI/#dfn-filereader
中的更多详情