Permalink
Browse files

Return files for all file inputs of the given jQuery object. Fixes #1…

…678.

If the given file input doesn't have an associated form, use the
default widget file input's form.
  • Loading branch information...
1 parent 6b6bee1 commit d5548c31b783e60890c84a3d8819344a7be42efe @blueimp committed Sep 14, 2012
Showing with 23 additions and 3 deletions.
  1. +23 −3 js/jquery.fileupload.js
View
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload Plugin 5.17
+ * jQuery File Upload Plugin 5.17.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -440,6 +440,11 @@
// associated form, if available:
if (!options.form || !options.form.length) {
options.form = $(options.fileInput.prop('form'));
+ // If the given file input doesn't have an associated form,
+ // use the default widget file input's form:
+ if (!options.form.length) {
+ options.form = $(this.options.fileInput.prop('form'));
+ }
}
options.paramName = this._getParamName(options);
if (!options.url) {
@@ -848,7 +853,7 @@
).promise();
},
- _getFileInputFiles: function (fileInput) {
+ _getSingleFileInputFiles: function (fileInput) {
fileInput = $(fileInput);
var entries = fileInput.prop('webkitEntries') ||
fileInput.prop('entries'),
@@ -861,7 +866,7 @@
if (!files.length) {
value = fileInput.prop('value');
if (!value) {
- return $.Deferred().reject([]).promise();
+ return $.Deferred().resolve([]).promise();
}
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
@@ -871,6 +876,21 @@
return $.Deferred().resolve(files).promise();
},
+ _getFileInputFiles: function (fileInput) {
+ if (!(fileInput instanceof $) || fileInput.length === 1) {
+ return this._getSingleFileInputFiles(fileInput);
+ }
+ return $.when.apply(
+ $,
+ $.map(fileInput, this._getSingleFileInputFiles)
+ ).pipe(function () {
+ return Array.prototype.concat.apply(
+ [],
+ arguments
+ );
+ });
+ },
+
_onChange: function (e) {
var that = e.data.fileupload,
data = {

0 comments on commit d5548c3

Please sign in to comment.