5

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

Saeed Hamed
  • 732
  • 2
  • 10
  • 28

1 Answers1

10

you try this:

for (int i = 0; i < Request.Files.Count; i++)
{
    if (Request.Files.GetKey(i) == "keyName")
    {
        HttpPostedFileBase fileUpload = Request.Files.Get(i);
    }
}
Elena
  • 125
  • 1
  • 9