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

Commit f60bbfb

Browse files
committedJan 21, 2013
Trigger a manual progress event when upload is done but loaded doesn't equal total uploaded bytes.
1 parent 1c0df67 commit f60bbfb

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed
 

‎js/jquery.fileupload.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,10 @@
570570
.done(function (result, textStatus, jqXHR) {
571571
ub = that._getUploadedBytes(jqXHR) ||
572572
(ub + o.chunkSize);
573-
// Create a progress event if upload is done and
574-
// no progress event has been invoked for this chunk:
575-
if (!o.loaded) {
573+
// Create a progress event if upload is done and no progress
574+
// event has been invoked for this chunk, or there has been
575+
// no progress event with loaded equaling total:
576+
if (!o.loaded || o.loaded < o.total) {
576577
that._onProgress($.Event('progress', {
577578
lengthComputable: true,
578579
loaded: ub - o.uploadedBytes,
@@ -632,12 +633,16 @@
632633
},
633634

634635
_onDone: function (result, textStatus, jqXHR, options) {
635-
if (!this._isXHRUpload(options)) {
636-
// Create a progress event for each iframe load:
636+
if (!this._isXHRUpload(options) || !options.loaded ||
637+
options.loaded < options.total) {
638+
var total = this._getTotal(options.files) || 1;
639+
// Create a progress event for each iframe load,
640+
// or if there has been no progress event with
641+
// loaded equaling total for XHR uploads:
637642
this._onProgress($.Event('progress', {
638643
lengthComputable: true,
639-
loaded: 1,
640-
total: 1
644+
loaded: total,
645+
total: total
641646
}), options);
642647
}
643648
options.result = result;

0 commit comments

Comments
 (0)
This repository has been archived.