Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome WebKitBlobBuilder doesn't append data
    text
    copied!<p>I'm implementing some file upload feature through ajax request. I'd like to be able to send multiple files in one ajax call, so i decided to use FormData.</p> <p>I tried to append my binary data string directly to the FormData (and it works), but the Content-Disposition doesn't have a filename attribute: Content-Disposition: form-data; name="file1"</p> <p>w3c says that i need to append a blob object to the formdata to have that attribute (or to be able to set it with the 3rd attribute of FormData.append())</p> <p>I wrote the following code:</p> <pre><code>function uploadAsBinary() { var xhr = new XMLHttpRequest(); var fd = new FormData(); window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder; var bb = new window.BlobBuilder(); bb.append("this is my binary content"); var blob = bb.getBlob("text/plain"); fd.append("file1", blob, "file1"); xhr.open("POST", "/mb/0/", false); xhr.send(fd); } </code></pre> <p>It works perfectly fine with firefox, but with google chrome (v16 and v17), the request payload is a formdata without content in it:</p> <pre><code>------WebKitFormBoundaryVkgESMAGtmPMlPZ7 Content-Disposition: form-data; name="file1"; filename="file1" Content-Type: text/plain ------WebKitFormBoundaryVkgESMAGtmPMlPZ7-- </code></pre> <p>I've also tried to fill the blob through an ArrayBuffer, same result. I've been surfing the web for 2 days now, i've found no answer. I've found an open issue on android (http://code.google.com/p/android/issues/detail?id=22441) but it seems quite dead.</p> <p>Is this a real chrome issue ? Does someone have a clue about this, or should i open an issue on chromium tracker ?</p> <p>Thx for your help !</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload