Closed esneko closed 13 years ago
The plugin actually submits multiple files if more than one has been selected in Opera, using the iframe method (which is basically the same as a non-JavaScript form submit). Due to the missing File API, only the filename of one of the files is accessible via JavaScript (via the file input value), not the complete file list and it's only possible to submit all the selected files with one request.
There also seems to be a bug in PHP related to the way the multiple file upload is implemented in Opera: PHP Bug 47789.
Since it's still possible to select and submit multiple files with Opera I'm reluctant to disable it in the plugin code itself, although the support is kind of limited and requires additional work on server-side to accept multi-file requests.
However, you can easily remove (or add) the multiple option via JavaScript depending on the implementation of the File API without having to adjust the plugin code itself:
if (typeof File === 'undefined') {
$('#file_upload').find('input:file').removeAttr('multiple');
}
OK, Opera ignores just removing the multiple attribute, here's a tested solution that removes the multiple attribute and replaces the input field with a clone (which does the trick with Opera):
$('#file_upload').each(function () {
// Fix for browsers which support multiple file selection but not the File API:
// https://github.com/blueimp/jQuery-File-Upload/issues#issue/36
if (typeof File === 'undefined') {
$(this).find('input:file').each(function () {
$(this).removeAttr('multiple')
// Fix for Opera, which ignores just removing the multiple attribute:
.replaceWith($(this).clone(true));
});
}
}).fileUploadUI(fileUploadOptions);
Another problem With Opera 11.10. It implements XMLHttpRequest but not jet XMLHttpRequestUpload - crazy. So i modified isXHRUploadCapable with additional type check for it like this:
isXHRUploadCapable = function () { return typeof XMLHttpRequest !== undef && typeof XMLHttpRequestUpload !== undef && typeof File !== undef && ( !settings.multipart || typeof FormData !== undef || typeof FileReader !== undef ); },
Thanks for your info.
I added a check for XMLHttpRequestUpload in this commit.
With opera 11.01, jquery file upload appears to send only one pair of name/value to server for multiple files:
Name contains constant value "file", and value carries the concatenation of the contents of uploaded files.
Is it possible to split this one pair of name/value into the same number of pairs as uploaded files for "legacy browsers" (namely m$ IE)?
With the latest update, jQuery File Upload supports multiple file selection for Opera 11.10.
IE 8 not suport multiple file selection
Hi, almost one year later, I'm not sure if this bug has come back in Opera 11.64. Whenever I try to upload multiple files with Opera, only one file is uploaded. Everything works just fine with Chrome, Safari and FF. I'm using the basic plugin, as described here: https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin.
I cannot reproduce any problems with uploading multiple files on Opera 11.64.
Please note that Opera only supports multi-file upload requests for multiple selected files, not splitting them up in single upload requests, as only the iFrame transport is supported on Opera.
Unfortunately, you cannot really test it on the demo, as due to the cross-origin upload, the JSON response appended to the URL redirect will get too long and result in an error, but this is a completely different issue and can be avoided by using short JSON responses (which is not feasible for the demo).
Thanks for the lightspeed answer! Is the iFrame transport fallback supposed to be transparent for the programmer? If I display an alert each time the "done" fallback is called, it appears only once with opera, although multiple files where selected. With other browsers, I get an alert for each uploaded file.
What's more, if I log the parameters passed to my rails controller, I can only see one single file. Could it be this issue has to do with rails/rack maybe?
That's the limitation I was talking about: Opera supports multiple file selection, but not XHR uploads, therefore multiple selected files will be uploaded in one request. https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support
However on server-side, multiple files should be uploaded. Some environments (like PHP) require the file input parameter name to include brackets for multiple file uploads, e.g. "files[]", however in rails you should be able to iterate over each request parameter. I'm not aware of any problem due to using rack (which seems to be pretty most standard for modern rails deployments).
Brackets were the problem. I had to name my field like this in order to make it work with rails/paperclip: name="upload[][content]".
I didn't notice anything on Chrome, FF, Safari because uploads on these browsers are done through XHR, with one single file per request.
Thanks a lot for your help.
You're welcome. :)
The problem seems to exist with Opera 11.
Opera supports multiple files selection from last version using standard syntax (not "min" and "max" options as before). But there are not implemented XHR2 and FileAPI as well yet.
So I suppose plugin should process multiple upload as scope of iframe uploads. If it's not possible, then multiple option for Opera should be just disabled with plugin initialization.