Vibe.d form file attributes

aberba via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 20 10:22:51 PST 2016


In PHP, I am able to access the name attribute of multiple files 
submitted through forms at the server side in $_FILES global.

For example, a file input with name="picture[]" will allow me to 
upload multiples files with the same attribute name. This can be 
access in PHP as;

  $files =  $_FILES["picture"]; // This filter out only files with 
a name attribute of "picture[]"

foreach ($files as $file) {
     $filename = $file["name"];
     ...
}



Now I wanted to implement this in D (vibe.d) and here is what I 
did in the file upload handler.

void upload(HTTPServerRequest req, HTTPServerResponse res)
{
     import std.stdio;

     foreach(picture; req.files) // req.files includes all 
uploaded files
     {
         ...
     }	
}
However, I want to filter out only those files with attribute 
name of "picture[]" from req.files.  I tried req.files.name == 
"picture[]" and other combination but there seem to be no 
property like that (How do I print all properties of req.files by 
the way? :) ).

Any help on this?


More information about the Digitalmars-d-learn mailing list