Generate file upload input for property with “DataType.Upload” attribute?

后端 未结 3 1347
野趣味
野趣味 2021-01-07 05:50

I have the following view model.

public class MyViewModel
{
    [DataType(DataType.Upload)]
    public HttpPostedFileBase ImageUpload { get; set; }

    publ         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-07 06:09

    Change your image control to this,

      @Html.TextBoxFor(m => m.ImageUpload, new { type = "file", name = "Files" })
    

提交回复
热议问题