XMLHttpRequest: Browser support for sendAsBinary? XMLHttpRequest: Browser support for sendAsBinary? ajax ajax

XMLHttpRequest: Browser support for sendAsBinary?


At the moment, I believe only FF3+ supports this, though there is a workaround for Chrome.


The links around http://code.google.com/p/chromium/issues/detail?id=35705 are very confusing, but I do not think there is any workaround on Chrome 8 for POST'ing binary data.

You can convert the data to base64 and upload that, but then the server has to be able to decode it.

Chrome 9 (currently in Dev channel, not even Beta yet) lets you do XmlHttpRequest.send(blob) where the blob's bytes are sent as-is (not converted to utf-8), so the non-standard XmlHttpRequest.sendAsBinary() is not necessary for binary file uploads.

You must create this blob from the "binary" string that is in evt.target.result after a successful FileReader.readAsBinaryString(). That requires using ArrayBuffer and Uint8Array, which are not available in Chrome 8.


As far as I know, yes, only Firefox supports it. It's not part of the W3C standard, so there's no guarantee that it'll ever be supported by any other browser.