plupload icon indicating copy to clipboard operation
plupload copied to clipboard

HTML5 uploading breaks on Safari 5.1 (OS X Lion DP4)

Open scomma opened this issue 15 years ago • 83 comments

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')
  }
});

scomma avatar Jun 29 '11 05:06 scomma

Confirm. Safari sends [object File] instead file contents https://gist.github.com/1063983#L17

yury avatar Jul 04 '11 21:07 yury

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.)

gonchuki avatar Jul 06 '11 14:07 gonchuki

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)

yury avatar Jul 06 '11 15:07 yury

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 ) {

ryandemmer avatar Jul 21 '11 11:07 ryandemmer

Yep, upload is broken on final Safari 5.1 with html5

sergiosilva avatar Jul 21 '11 15:07 sergiosilva

Yes we are experiencing this as well. A proper fix would be very appreciated! Thanks in advance!

TooTallNate avatar Jul 21 '11 17:07 TooTallNate

The ryandemmer fix works but it's an hack...

sergiosilva avatar Jul 21 '11 17:07 sergiosilva

@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.

gonchuki avatar Jul 22 '11 16:07 gonchuki

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

fortybillion avatar Jul 22 '11 20:07 fortybillion

I can confirm that @gonchuki's fix works like a charm :)

DonDebonair avatar Jul 27 '11 09:07 DonDebonair

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

jdejong avatar Jul 27 '11 15:07 jdejong

Has anyone actually sent a pull request with a fix?

ryandemmer avatar Jul 27 '11 16:07 ryandemmer

@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.

gonchuki avatar Jul 27 '11 20:07 gonchuki

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.

ryandemmer avatar Jul 28 '11 09:07 ryandemmer

I have sent a pull request - https://github.com/moxiecode/plupload/pull/333

ryandemmer avatar Jul 28 '11 09:07 ryandemmer

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 avatar Jul 28 '11 13:07 atoomkern

@atoomkern I have similar issue when uploading multiple files on Safari 5.1, but with 5.0 everything works fine

tartakynov avatar Jul 29 '11 08:07 tartakynov

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.

oferreiro avatar Jul 29 '11 13:07 oferreiro

I am having also the same problem. It simply saying 'wrong content type'.

A fix would be very very appreciated! :) Thanks!

mrdoinel avatar Aug 01 '11 08:08 mrdoinel

I tried with @fortybillion fork's, then is ok on Safari 5.1.

oferreiro avatar Aug 01 '11 11:08 oferreiro