Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Trigger a manual progress event when upload is done but loaded doesn'…
Browse files Browse the repository at this point in the history
…t equal total uploaded bytes.
  • Loading branch information
blueimp committed Jan 21, 2013
1 parent 1c0df67 commit f60bbfb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions js/jquery.fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,10 @@
.done(function (result, textStatus, jqXHR) {
ub = that._getUploadedBytes(jqXHR) ||
(ub + o.chunkSize);
// Create a progress event if upload is done and
// no progress event has been invoked for this chunk:
if (!o.loaded) {
// Create a progress event if upload is done and no progress
// event has been invoked for this chunk, or there has been
// no progress event with loaded equaling total:
if (!o.loaded || o.loaded < o.total) {
that._onProgress($.Event('progress', {
lengthComputable: true,
loaded: ub - o.uploadedBytes,
Expand Down Expand Up @@ -632,12 +633,16 @@
},

_onDone: function (result, textStatus, jqXHR, options) {
if (!this._isXHRUpload(options)) {
// Create a progress event for each iframe load:
if (!this._isXHRUpload(options) || !options.loaded ||
options.loaded < options.total) {
var total = this._getTotal(options.files) || 1;
// Create a progress event for each iframe load,
// or if there has been no progress event with
// loaded equaling total for XHR uploads:
this._onProgress($.Event('progress', {
lengthComputable: true,
loaded: 1,
total: 1
loaded: total,
total: total
}), options);
}
options.result = result;
Expand Down

0 comments on commit f60bbfb

Please sign in to comment.