User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0 Build Identifier: Sending a Blob with FormData, and empty filename is sent: var blob = file.slice(0, 10); var formData = new FormData(); formData.append('file', blob); This gets send to the server: Content-Disposition: form-data; name="file"; filename="" Sending an empty filename for a multipart file results in errors on some backends, i.e. Django does not recognize this as a file. and treats it as a key/value POST instead. Chrome sends this instead: Content-Disposition: form-data; name="file"; filename="Blobf98dc705ce2d4f82af47b470950a3c2c" Firefox should also set a random value for filename since this is expected by many multipart parsers. Reproducible: Always
Created attachment 526515 [details] Testcase for this bug (should be loaded from a non-file:/// url) This test case shows a file input, and when a file gets selected tries to upload the first Kb of that file to the current URL. The file can't be opened directly, as POSTs to "file:" urls gets denied. Open from a local server instead. Watching the sent data with a sniffer yelds the results Jan Gerber comments, with a filename="" on the POST. This causes PHP (and others) to reject the file, even if data was sent correctly.
Summary: FormatData of Blob does not set a filename → Blobs do not have a filename if send via FormData
8 years ago
Summary: Blobs do not have a filename if send via FormData → Blobs do not have a filename if sent via FormData
Ugh. This needs to be specified in the spec for FormData :(
Is sending an empty string allowed according to the rfcs describing multipart/form-data?
Jonas, what do you need to make progress? Can you or Arun do the spec work required?
The spec side is blocked by Anne who is on a looooong trek. Suspect we should do this one ourselves. Buried in sheriff stuff right now, but would love help remembering to fix this monday.
(In reply to comment #5) > Buried in sheriff stuff right now, but would love help remembering to fix > this monday. Which monday were you talking about? :)
Any, really :)
Assignee: nobody → jonas
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Hi. Last update was 22 days ago.
Created attachment 542696 [details] [diff] [review] Patch to fix
Attachment #542696 - Flags: review?(mounir.lamouri)
Comment on attachment 542696 [details] [diff] [review] Patch to fix Review of attachment 542696 [details] [diff] [review]: -----------------------------------------------------------------
Attachment #542696 - Flags: review?(mounir) → review+
Checked in. Thanks for the quick review! http://hg.mozilla.org/mozilla-central/rev/c48c74bc146b
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
This was fixed in Firefox 7.
Target Milestone: --- → mozilla7
Documentation updated: https://developer.mozilla.org/en/DOM/XMLHttpRequest/FormData https://developer.mozilla.org/en/DOM/XMLHttpRequest/Using_XMLHttpRequest#Sending_files_using_a_FormData_object And mentioned on Firefox 7 for developers.
Keywords: dev-doc-needed → dev-doc-complete
Duplicate of this bug: 680423
Keywords: testcase-wanted → testcase
As visible here: https://tbpl.mozilla.org/php/getParsedLog.php?id=6407277&full=1 the test referenced in this bug (content/base/test/fileutils.js) has passed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.