所有的人都在问同样的问题,在所有主题和论坛中都没有答案。
$('#fileupload').fileupload({
dropZone: $("#dragandrop"),
pasteZone: $("#dragandrop"),
//singleFileUploads: false,
//progressInterval:50,
//bitrateInterval:500,
//forceIframeTransport: true,
dataType: 'json',
add: function (e, data) {
data.submit();
},
progress: function (e, data) {
//if (data.loaded == data.total ) {
// if (e.lengthComputable) {
var progress = parseInt(data._progress.loaded / data.total * 100, 10);
console.log(data.loaded + " " + data.total + " " + data.bitrate);
$('#progress .bar').css('width', progress + '%');
//}
},
always: function (e, data) {
$('#progress .progress-bar').css('width',0);
},
done: function (e, data) {
var result = data.result.data;
//add the flash success message
$('#trust-center-flash-message').html(result.message);
//add the new images to the preview
previewImages(result.attachments);
return alert("done");
}
});
我尝试了互联网上的所有解决方案。 我没有使用插件后端 php 类。
最佳答案
The progress event only tracks the progress of the upload, not the progress of the request.
解决此问题的一种方法是更新我们对进度事件的响应方式。
One solution would be to have your progress bar stop at say, 90% then bump it to 100% in the done callback. simply multiply data.total by 1.1
progress: function (e, data) { var progress = parseInt(data.loaded / (data.total*1.1) * 100, 10); var bar = data.context.children().children(".progress"); $(bar).css("width", progress + "%"); },
您也可以对事件“progressall”执行此操作,具体取决于您要修改的事件。
对于所有回调see the API ,以下是一些您可能感兴趣的内容
$('#fileupload')
...
.bind('fileuploadprogress', function (e, data) {/* ... /})
.bind('fileuploadprogressall', function (e, data) {/ ... /})
.bind('fileuploadchunkdone', function (e, data) {/ ... /})
...
.bind('fileuploadprocessdone', function (e, data) {/ ... */})
关于php - blueimp Jquery上传插件: Large gap between last file progress hitting 100% and the done event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29277621/