mvc upload file with model - second parameter posted file is null

后端 未结 4 1289
南旧
南旧 2020-12-05 13:35

I have a simple model with 1 string property which I render on a simple view.

the view looks like the following:

@using (Html.BeginForm(\"UploadFile\         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 14:19

    Change your name file to fileUpload and enctype it's work

    @using (Html.BeginForm("UploadFile", "Home", FormMethod.Post, new { enctype="multipart/form-data" }))
    {
        @Html.TextBoxFor(m => m.FirstName)
        



    } [HttpPost] public ActionResult UploadFile(UploadFileModel model, HttpPostedFileBase fileUpload) { // DO Stuff return View(model); }

提交回复
热议问题