HTTPPostedFileBase always return null in controller

后端 未结 3 1168
礼貌的吻别
礼貌的吻别 2021-01-27 03:03

I have checked various answer for this, but none of them works for me, my code in .cshtml is as follows:


         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-27 03:45

    try this one:

    var fileCount = Request.Files.Count;
    if (fileCount > 0)
    {
     for (int i = 0; i < (fileCount); i++)
        { 
            HttpPostedFileBase Yourfile= Request.Files[i] as   HttpPostedFileBase;
            // do whatever with your file
        }
    }
    

提交回复
热议问题