我正在使用 BlueImp 的 jQuery 文件上传
var fileInput = $('#'+file_up_id+'_select');
var fileUploadObj = $(fileInput).fileupload({
url: file_up_submitUrl,
dataType: 'json',
maxNumberOfFiles:1,
autoUpload: false,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
})
.on('fileuploadadd',onFileSelect)
.on('fileuploadprogressall',onFileUploadProgress)
.on('fileuploaddone',onFileUploadDone)
.on('fileuploadfail',onFileUploadFail);
onFileUploadProgress=function (e, data) {
uploadProgress = parseInt(data.loaded / data.total * 100, 10);
}
onFileUploadFail=function (e, data) {
console.log("failed");
}
onFileUploadDone=function (e, data) {
console.log("done");
}
HTML 是
<form method='POST' enctype='multipart/form-data' >
<b>Select a file</b><input type='file' id='myImgUpload_select' name='files[]' single />
</form>
我的问题是上传失败时,会多次调用 fileuploadfailed 回调。否则一切正常
提前致谢