Skip to content

Commit 64a5f8b

Browse files
committed
Check for Blob and File objects to accomodate old Firefox versions. Fixed blueimp#1880.
1 parent ce12029 commit 64a5f8b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

js/jquery.fileupload.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.19.3
2+
* jQuery File Upload Plugin 5.19.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/*jslint nomen: true, unparam: true, regexp: true */
13-
/*global define, window, document, Blob, FormData, location */
13+
/*global define, window, document, File, Blob, FormData, location */
1414

1515
(function (factory) {
1616
'use strict';
@@ -209,10 +209,10 @@
209209
if (typeof options.formData === 'function') {
210210
return options.formData(options.form);
211211
}
212-
if ($.isArray(options.formData)) {
212+
if ($.isArray(options.formData)) {
213213
return options.formData;
214214
}
215-
if (options.formData) {
215+
if (options.formData) {
216216
formData = [];
217217
$.each(options.formData, function (name, value) {
218218
formData.push({name: name, value: value});
@@ -345,10 +345,12 @@
345345
formData.append(paramName, options.blob, file.name);
346346
} else {
347347
$.each(options.files, function (index, file) {
348-
// File objects are also Blob instances.
348+
// Files are also Blob instances, but some browsers
349+
// (Firefox 3.6) support the File API but not Blobs.
349350
// This check allows the tests to run with
350351
// dummy objects:
351-
if (file instanceof Blob) {
352+
if ((window.Blob && file instanceof Blob) ||
353+
(window.File && file instanceof File)) {
352354
formData.append(
353355
options.paramName[index] || paramName,
354356
file,
@@ -758,7 +760,8 @@
758760
that._onSend(e, this);
759761
return this.jqXHR;
760762
};
761-
return (result = that._trigger('add', e, newData));
763+
result = that._trigger('add', e, newData);
764+
return result;
762765
});
763766
return result;
764767
},

0 commit comments

Comments
 (0)