On Wed, 26 Feb 2014 23:21:18 GMT, Colin Grogan wrote:
Hi, I'm trying to upload more than 1 image at a time.
My client side form is:
form(method="POST", action="/photo_upload", enctype="multipart/form-data") input(type="file", name="imagesToUpload", id="imagesToUpload", multiple) button(type="submit", id="doUploadButton") Upload
And server side (I havent implemented the file copyies yet, I'm only reading the info from the headers for now)
private void postPhotoUpload(HTTPServerRequest req, HTTPServerResponse res){ import std.stdio; debug{ writefln("req headers:"); foreach(key, val; req.headers) writefln("\t%s : %s",key, val); writefln("req files:"); foreach(key, val; req.files) writefln("\t%s : %s", key, val); } res.writeBody("Test upload", "text/plain"); }
Again, I havent implemented the actual file copies yet, however, I can see from the req.files array that only 1 file is ever being populated there.
This is the output when I select two files to upload via the client.
imagesToUpload : FilePart(DictionaryList!(string, false)([Field(575136612, "Content-Disposition", "form-data; name=\"imagesToUpload\"; filename=\"image.png\""), Field(982413131, "Content-Type", "image/png"), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", ""), Field(0, "", "")], 2, []), image.png, /tmp/vtmp.VBh4mv)
Any idea whats going on here?
Thanks!
Looking at the file that actually gets through, its always the last one I select. My guess is that because req.files is an array[string], and the key is the same in each case, the array[string] is just over-ridden every time. Would this make sense?