gpt4 book ai didi

javascript - 精细上传异步任务在 Chrome 中有效,但在 IE11 中无效

转载 作者:行者123 更新时间:2023-11-28 01:15:43 28 4
gpt4 key购买 nike

我使用Fineuploader Promise在提交回调中运行 md5 检查以防止已存在的文件再次上传,它在 chrome 中有效,但在 IE11 中无效。不是 IE bug 还是我做错了?我该如何修复它?多谢。这是脚本:

 $("#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
}

最佳答案

在我的代码中,我使用 FileReader.readAsBinaryString() 方法读取文件,IE11 不再支持它。更多详情请参见FileReader.readAsBinaryString function-- doesnt work on IE11http://www.w3.org/TR/FileAPI/#dfn-filereader

关于javascript - 精细上传异步任务在 Chrome 中有效,但在 IE11 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23857999/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com