Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all files from Request.Files with same Key

I have some files with the same keys in Request.Files object and when I use this code Request.Files.Keys["keyName"] it returns just one file but I have more than one file with that key. what should I do?! By the way I can't use key names as argument because I don't know what key exactly is, maybe model binder can help in this case but I don't know how can I use it for Files. Thanks

like image 269
Saeed Hamed Avatar asked Nov 02 '13 09:11

Saeed Hamed


1 Answers

you try this:

for (int i = 0; i < Request.Files.Count; i++)
{
    if (Request.Files.GetKey(i) == "keyName")
    {
        HttpPostedFileBase fileUpload = Request.Files.Get(i);
    }
}
like image 93
Elena Avatar answered Sep 20 '22 15:09

Elena