我尝试设置plupload,以便根据某个错误代码文件上传失败,plupload会尝试再次上传。没有成功。
我目前拥有什么
以下是我的代码:
var attempts = 0; // number of attempts
function init(uploader) {
uploader.bind('Error', function(up, file) {
var code = JSON.parse(file.response).error.code;
console.log(code); //logs the error code
if(code === 503 && attempts > 3) {
up.stop();
file.status = plupload.FAILED;
file.retry = false;
// do stuff...
up.state = plupload.STARTED;
up.trigger("StateChanged");
attempts = 0;
}
else {
console.log("attempt : "+ attempts);
up.stop();
file.status = plupload.QUEUED;
attempts++;
file.retry = true;
up.state = plupload.STARTED;
up.trigger("StateChanged");
up.trigger("QueueChanged"); // ERROR HERE
}
})
}
我在这里指出了错误" ERROR HERE",我的控制台告诉我这个:
TypeError:n.getSource不是函数
我做错了什么?
非常感谢!
答案 0 :(得分:0)
为什么不在队列中再次添加文件? http://www.plupload.com/docs/Uploader#addFile-filefileName-method
addFile(file, [fileName])