The background:
According to W3c, multiple files selected in a <input>
field, should be send by "multipart/mixed" type with separate boundary string and only one "name" parameter (as long, as the name should be unique in the form).
Writing POST data processing, I noticed that the major browsers send such multiple files as if they origins from different <input>
elements, but with the same name. I.e. Instead of:
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=BbC04y
--BbC04y
Content-Disposition: file; filename="file1.txt"
Content-Type: text/plain
... contents of file1.txt ...
--BbC04y
Content-Disposition: file; filename="file2.gif"
Content-Type: image/gif
...contents of file2.gif...
--BbC04y--
--AaB03x--
...they send something like:
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain
... contents of file1.txt ...
--BbC04y
Content-Disposition: form-data; name="files"; filename="file2.gif"
Content-Type: image/gif
...contents of file2.gif...
--AaB03x--
The question:
How I should process the POST data? Are there browsers that will send multiple files as a "multipart/mixed" or handling such case is not needed and I should simplify my code?
Notice: I am writing framework for handling HTTP, so using other libraries and frameworks is not an option.