Large gap between last file progress hitting 100% and the stop/done events?

后端 未结 1 825
栀梦
栀梦 2021-01-21 05:19

I am using the blueimp File Upload plugin to implement some file upload functionality and I\'ve noticed that there can be large gaps of time between when my last file progress b

相关标签:
1条回答
  • 2021-01-21 06:06

    When you upload a file, the file is first (obviously) uploaded to the server, the server then will execute the requested server-side script where you then handle the file. If the "handle the file" part of the request isn't instant, there will be a delay between the progress reaching 100% and the done callback being triggered. There may also be a delay if there is network lag.

    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 + "%");
            },
    
    0 讨论(0)
提交回复
热议问题