Uploading files with MVC 3

后端 未结 3 1184
走了就别回头了
走了就别回头了 2021-01-15 01:23

I\'m growing thin learving mvc3. I have the following code in my controller

    [HttpPost]
    public ActionResult Accreditation(Accreditation accreditation)         


        
3条回答
  •  没有蜡笔的小新
    2021-01-15 02:16

    var fileUpload = Request.Files[0]; is the line where you have your exception, isn't it? You should expect the file to be stored in the property of class Accreditation, not in Request.Files.

    So you need properties PressCard and Passport in Accreditation, both of type HttpPostedFileBase, and then use these properties in your code.

提交回复
热议问题