更新时间:2023-02-25 13:26:02
HttpFileCollection
上的枚举器返回文件的键(名称),而不是 HttpPostedFileBase
对象.获得密钥后,使用带有密钥(文件名)的 Item
([]
) 属性来获取 HttpPostedFileBase
对象.
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];
...
}