Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions js/jquery.fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
bitrateInterval: 500,
// By default, uploads are started automatically when adding files:
autoUpload: true,
// Android4 : Reflection of the formData object to acces its properties,
// (formData properties cannot be accessed)
formDataObject: {},

// Error and info messages:
messages: {
Expand Down Expand Up @@ -451,13 +454,16 @@
name: paramName,
value: options.blob
});
options.formDataObject[paramName]=options.blob;
} else {
$.each(options.files, function (index, file) {
formData.push({
name: ($.type(options.paramName) === 'array' &&
options.paramName[index]) || paramName,
value: file
});
options.formDataObject[($.type(options.paramName) === 'array' &&
options.paramName[index]) || paramName]=file;
});
}
} else {
Expand All @@ -467,10 +473,12 @@
formData = new FormData();
$.each(this._getFormData(options), function (index, field) {
formData.append(field.name, field.value);
options.formDataObject[field.name]=field.value;
});
}
if (options.blob) {
formData.append(paramName, options.blob, file.name);
options.formDataObject[paramName]=options.blob;
} else {
$.each(options.files, function (index, file) {
// This check allows the tests to run with
Expand All @@ -483,6 +491,8 @@
file,
file.uploadName || file.name
);
options.formDataObject[ ($.type(options.paramName) === 'array' &&
options.paramName[index]) || paramName]=file;
}
});
}
Expand Down Expand Up @@ -1535,23 +1545,24 @@
this.segments = [];

// Loop through our submitted form data, adding it to the POST
for (i = 0; i < options.data.length; i++) {
if (options.data[i].value instanceof Blob && options.files[fileNumber] instanceof File) {
for (i in options.formDataObject) {
var ldata=options.formDataObject[i];
if (ldata instanceof Blob && (options.files[fileNumber] instanceof File || options.files[fileNumber] instanceof Blob)) {
fileReader = new FileReader();
fileReader.segmentIdx = this.segments.length;
fileReader.owner = this;
fileReader.onload = pushSegment;
this.segments.push(
'Content-Disposition: form-data; name="' + options.data[i].name + '"; ' +
'Content-Disposition: form-data; name="' + i + '"; ' +
'filename="' + options.files[fileNumber].name + "\"\r\n" +
'Content-Type: ' + options.data[i].value.type + "\r\n\r\n"
'Content-Type: ' + ldata.type + "\r\n\r\n"
);
this.status++;
fileNumber++;
fileReader.readAsBinaryString(options.data[i].value);
fileReader.readAsBinaryString(ldata);
} else {
this.segments.push(
"Content-Disposition: form-data; name=\"" + options.data[i].name + "\"\r\n\r\n" + options.data[i].value + "\r\n"
"Content-Disposition: form-data; name=\"" + i + "\"\r\n\r\n" + ldata + "\r\n"
);
}
}
Expand Down