我有一个手动激活的上传器的实例:
var manualuploader = new qq.FineUploader({
element: $('#jquery-wrapped-fine-uploader')[0],
request: {
endpoint: '/data/assets/ajax/uploader.php'
},
autoUpload: false,
text: {
uploadButton: '<i class="icon-plus icon-white"></i> Select Files to upload'
},
chunking: {
enabled: true,
partSize: 50000000
},
resume: {
enabled: true
},
debug: true,
callbacks: {
onComplete: function (id, fileName, response) {
$('#uploader').append('<input type="hidden" name="fileasdf[]" value="' + response.originalName + '" />');
submitForm.call(this);
},
onError: function (event, id, name, errorReason, xhrOrXdr) {
alert(qq.format("Error on file number {} - {}. Reason: {}", id, name, errorReason));
}
}
});
$('#triggerUpload').click(function() {
manualuploader.uploadStoredFiles();
});
我指定了一个chunk文件夹,我可以看到上传的块。文件上载过程正常完成。
但是,如果取消或意外终止,则不会恢复上传。块仍然存在于目录中,所有标准浏览器cookie都已启用,但简历不会发生。
分块调试输出如下。我上传了几个块,取消并重新尝试上传:
[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 1-50000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] xhr - server response received for 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] responseText = {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received response status 200 with body: {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 50000001-100000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] xhr - server response received for 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] responseText = {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received response status 200 with body: {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 100000001-150000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Detected valid file button click event on file 'CentOS-6.3-x86_64-minimal.iso', ID: 1. fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Cancelling 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Caught exception in 'onError' callback - Cannot read property 'length' of undefined fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received 1 files or inputs. fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 2: bytes 1-50000000 of 346011648
知道为什么会这样吗?
我还有另一个与问题无关的查询。对于onComplete回调,我只想触发submitForm.call(this)函数(提交表单)。但是,如果我只指定onComplete: submitForm.call(this)
,则会抛出错误,表示未定义onComplete响应...
为赛格威道歉,再次感谢。
答案 0 :(得分:0)
取消的文件不符合恢复条件。此外,从5.0开始,cookie不再用于保留简历数据:我们使用localStorage
代替。您的日志消息表明该文件已被取消,这意味着它无法恢复。
onComplete回调需要一个函数作为值。相反,您正在调用一个函数并将该函数的返回值设置为onComplete
的值。这听起来像是对Function.prototype.call
在JavaScript中的作用的误解。 call
执行一个函数。如果要使用备用上下文构造新函数,请改用Function.prototype.bind
。请注意,IE8及更早版本不支持bind
。如果您需要支持IE8或更早版本,可以使用Fine Uploader's bind alternative: qq.bind
。