I use Fineuploader Promise to run md5 check in submit callback to prevent the files already exist upload again,it works in chrome but not in IE11. is't a IE bug or i do it wrong?how can I fix it? Thanks a lot. here is the script:
$("#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
}
In my code I read file using FileReader.readAsBinaryString() method,it's no longer support by IE11. more details in FileReader.readAsBinaryString function-- doesnt work on IE11 and http://www.w3.org/TR/FileAPI/#dfn-filereader
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.