The enumerator on the HttpFileCollection
returns the keys (names) of the files, not the HttpPostedFileBase
objects. Once you get the key, use the Item
([]
) property with the key (filename) to get the HttpPostedFileBase
object.
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
...
}