Skip to content

Commit 58c0847

Browse files
committed
Transfer filename via Content-Disposition header if files[0] is not a File instance.
This is a workaround for browsers which don't support a filename param for FormData.append (e.g. Gecko).
1 parent 1b56aee commit 58c0847

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/jquery.fileupload.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.31.2
2+
* jQuery File Upload Plugin 5.31.3
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -379,9 +379,11 @@
379379
if (options.contentRange) {
380380
options.headers['Content-Range'] = options.contentRange;
381381
}
382-
if (!multipart) {
382+
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
383383
options.headers['Content-Disposition'] = 'attachment; filename="' +
384384
encodeURI(file.name) + '"';
385+
}
386+
if (!multipart) {
385387
options.contentType = file.type;
386388
options.data = options.blob || file;
387389
} else if ($.support.xhrFormDataFileUpload) {
@@ -414,8 +416,6 @@
414416
});
415417
}
416418
if (options.blob) {
417-
options.headers['Content-Disposition'] = 'attachment; filename="' +
418-
encodeURI(file.name) + '"';
419419
formData.append(paramName, options.blob, file.name);
420420
} else {
421421
$.each(options.files, function (index, file) {

0 commit comments

Comments
 (0)