HTML5 uploading breaks on Safari 5.1 (OS X Lion DP4)
The string [object File] gets uploaded in lieu of file content.
Safari version is 5.1 (7534.45) which comes with the latest preview of Mac OS X Lion. Tested on Chrome, etc. it works fine.
Config follows:
var uploader = new plupload.Uploader({
runtimes: "html5,flash,silverlight,gears,browserplus,html4",
browse_button: 'browser',
container: 'container',
drop_element: 'dropper',
max_file_size: '50mb',
url: resources,
flash_swf_url: "/javascripts/lib/plupload.flash.swf",
silverlight_xap_url: "/javascripts/lib/plupload.silverlight.xap",
multipart: true,
multipart_params: {
authenticity_token: $('meta[name=csrf-token]').attr('content')
}
});
Confirm.
Safari sends [object File] instead file contents
https://gist.github.com/1063983#L17
does this still happen if you disable multipart? (I just want to figure out if it's an issue on the multipart code or something on a lower level, don't have Lion to test.)
No, it doesn't work with multipart:false too. Actually, you can download Safari 5.1 preview (for Mac OS X SL and Win) from Safari Dev Center (registration is required, but it is free)
Safari 5.1 seems to support xhr.sendAsBinary so there is a bit of confusion when building the multipart request, because (!xhr.sendAsBinary) returns true for Safari 5.1, FormData is not used for the multipart parameters.
A quick 'n dirty fix is to change (line 599) :
if (!xhr.sendAsBinary) {
to
if (!xhr.sendAsBinary || fakeSafariDragDrop ) {
Yep, upload is broken on final Safari 5.1 with html5
Yes we are experiencing this as well. A proper fix would be very appreciated! Thanks in advance!
The ryandemmer fix works but it's an hack...
@ryandemmer: Safari 5.1 does not support sendAsBinary, what it does support is typed arrays and once again as I explained on other bug reports disabling the sendAsBinary hack on lines 21 to 29 fixes this issue.
I would just love if one of the plupload devs could jump in on this matter.
Furthermore, fakeSafariDragDrop isn't necessary for Safari 5.1 (and never was necessary for Safari 5.0 on Mac), so @gonchuki's fix is preferred.
I posted a somewhat dirty fix for the fakeSafariDragDrop issue which will work until I have time to explore Safari 5.1 feature detection further.
https://github.com/fortybillion/plupload/commit/3396432fd6f6791d34b5b712ca5966da3d7149bc
I can confirm that @gonchuki's fix works like a charm :)
Now that Lion is out, and most other Mac's are upgrading automagically to Safari 5.1 any update on getting a production fix pushed into the main code base? I would rather not use 'Hacks' in production (even though the fix seems like it is removing existing hacks). Thanks in advance.
-J
Has anyone actually sent a pull request with a fix?
@ryandemmer can't send a pull request unless we know why this hack was added in the first place. for that, we need a plupload dev to jump in and enlighten us, I'm just a random regular user which happens to have a lot of experience with the library and don't know what are the side effects of disabling the hack.
sendAsBinary is non-standard (according to Mozilla docs - https://developer.mozilla.org/en/XMLHttpRequest#sendAsBinary()) and seems to only be supported by Mozilla. Unless its significantly better than using xhr.send, I'm not sure why its necessary to patch in sendAsBinary.
From what I can see, removing the patch will have no effect, as xhr.send is used instead.
I have sent a pull request - https://github.com/moxiecode/plupload/pull/333
I have used the fix but there still seems to be a problem with uploading multiple files in Safary, all show up as 0 bytes and uploading results in empty files. Do other users also have this issue?
The same problem exists in the example: http://plupload.com/example_custom.php. Selecting one file shows the file size but when multiple are selected it shows 0 bytes.
@atoomkern I have similar issue when uploading multiple files on Safari 5.1, but with 5.0 everything works fine
I using git version.
html5 don't work: Safari 5.1 6534.50: Fail. File uploded content [object File].
html5 work: Chrome 12.0.742.122: ok. Firefox 5.0.1: ok. But don't open file dialog on click browse_button or when I'm using pluploadQueue on click in "add files" botton. Is possible use only with drag files.
I am having also the same problem. It simply saying 'wrong content type'.
A fix would be very very appreciated! :) Thanks!
I tried with @fortybillion fork's, then is ok on Safari 5.1.