Skip to content

Commit

Permalink
Pass the file name as third argument to FormData.append().
Browse files Browse the repository at this point in the history
This allows setting a file name property on Blob objects, which would otherwise be sent with a generic file name.
  • Loading branch information
blueimp committed Feb 11, 2012
1 parent 4922e27 commit c4a615a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/jquery.fileupload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery File Upload Plugin 5.6
* jQuery File Upload Plugin 5.6.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
Expand All @@ -16,7 +16,11 @@
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['jquery', './vendor/jquery.ui.widget', './jquery.iframe-transport'], factory);
define([
'jquery',
'./vendor/jquery.ui.widget',
'./jquery.iframe-transport'
], factory);
} else {
// Browser globals:
factory(window.jQuery);
Expand Down Expand Up @@ -289,14 +293,14 @@
});
}
if (options.blob) {
formData.append(options.paramName, options.blob);
formData.append(options.paramName, options.blob, file.name);
} else {
$.each(options.files, function (index, file) {
// File objects are also Blob instances.
// This check allows the tests to run with
// dummy objects:
if (file instanceof Blob) {
formData.append(options.paramName, file);
formData.append(options.paramName, file, file.name);
}
});
}
Expand Down

0 comments on commit c4a615a

Please sign in to comment.