Browse Source

Fix #1014: Enhancements to file upload single

Kartik Visweswaran 7 years ago
parent
commit
58467aa52f
3 changed files with 7 additions and 6 deletions
  1. 1 0
      CHANGE.md
  2. 6 6
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -7,6 +7,7 @@ Change Log: `bootstrap-fileinput`
 
 
 - (bug #1030): Correct image dimension validation to consider non JPEG images.
 - (bug #1030): Correct image dimension validation to consider non JPEG images.
 - (enh #1015): Enhancement to RTL styling.
 - (enh #1015): Enhancement to RTL styling.
+- (enh #1014): Enhancements to file upload single.
 - (enh #1012): Better formatting of ajax errors display.
 - (enh #1012): Better formatting of ajax errors display.
 - (enh #1006): Update Farsi Translations.
 - (enh #1006): Update Farsi Translations.
 
 

+ 6 - 6
js/fileinput.js

@@ -1912,7 +1912,7 @@
                 self.formdata.append(key, value);
                 self.formdata.append(key, value);
             });
             });
         },
         },
-        _uploadSingle: function (i, files, allFiles) {
+        _uploadSingle: function (i, allFiles) {
             var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
             var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
                 previewId = self.previewInitId + "-" + i, $thumb, chkComplete, $btnUpload, $btnDelete,
                 previewId = self.previewInitId + "-" + i, $thumb, chkComplete, $btnUpload, $btnDelete,
                 hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData),
                 hasPostData = self.filestack.length > 0 || !$.isEmptyObject(self.uploadExtraData),
@@ -2059,7 +2059,7 @@
             };
             };
             fnError = function (jqXHR, textStatus, errorThrown) {
             fnError = function (jqXHR, textStatus, errorThrown) {
                 var op = self.ajaxOperations.uploadThumb,
                 var op = self.ajaxOperations.uploadThumb,
-                    errMsg = self._parseError(op, jqXHR, errorThrown, (allFiles ? files[i].name : null));
+                    errMsg = self._parseError(op, jqXHR, errorThrown, (allFiles && self.filestack[i].name ? self.filestack[i].name : null));
                 uploadFailed = true;
                 uploadFailed = true;
                 setTimeout(function () {
                 setTimeout(function () {
                     if (allFiles) {
                     if (allFiles) {
@@ -2072,7 +2072,7 @@
                     self._showUploadError(errMsg, params);
                     self._showUploadError(errMsg, params);
                 }, 100);
                 }, 100);
             };
             };
-            formdata.append(self.uploadFileAttr, files[i], self.filenames[i]);
+            formdata.append(self.uploadFileAttr, self.filestack[i], self.filenames[i]);
             formdata.append('file_id', i);
             formdata.append('file_id', i);
             self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, previewId, i);
             self._ajaxSubmit(fnBefore, fnSuccess, fnComplete, fnError, previewId, i);
         },
         },
@@ -2304,7 +2304,7 @@
                 self._handler($el, 'click', function () {
                 self._handler($el, 'click', function () {
                     var $frame = $el.closest($h.FRAMES), ind = $frame.attr('data-fileindex');
                     var $frame = $el.closest($h.FRAMES), ind = $frame.attr('data-fileindex');
                     if (!$frame.hasClass('file-preview-error')) {
                     if (!$frame.hasClass('file-preview-error')) {
-                        self._uploadSingle(ind, self.filestack, false);
+                        self._uploadSingle(ind, false);
                     }
                     }
                 });
                 });
             });
             });
@@ -3622,8 +3622,8 @@
                 self.cacheInitialPreview = self.getPreview();
                 self.cacheInitialPreview = self.getPreview();
 
 
                 for (i = 0; i < len; i++) {
                 for (i = 0; i < len; i++) {
-                    if (self.filestack[i] !== undefined) {
-                        self._uploadSingle(i, self.filestack, true);
+                    if (self.filestack[i]) {
+                        self._uploadSingle(i, true);
                     }
                     }
                 }
                 }
                 return;
                 return;

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


Some files were not shown because too many files changed in this diff