我正在尝试设置 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
}
})
}
在我指出“此处错误”的地方,我的控制台向我显示了以下内容:
TypeError: n.getSource is not a function
我做错了什么?
非常感谢!
最佳答案
为什么不将该文件再次添加到队列中? http://www.plupload.com/docs/Uploader#addFile-filefileName-method
addFile(file, [fileName])
关于javascript - 如果出错,plupload 重试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31088932/