Upload multiple files with single input Asp Mvc

前端 未结 1 379
孤城傲影
孤城傲影 2021-01-15 23:14

I want to upload multiple files including Word Documents, Pdf and Images. I need to use a single input for files because we don\'t know how many files will be uploaded.

相关标签:
1条回答
  • 2021-01-15 23:47

    I order to upload files, your form needs to include the enctype= multipart/form-data attribute.

    <form name="registration"  action="" enctype= "multipart/form-data">
    

    or better

    @using (Html.BeginForm(actionName, controllerName, FormMethod.Post, new { enctype= "multipart/form-data" }))
    

    and I strongly recommend you pass a model to the view and use the strongly typed HtmlHelper methods to create your html for the properties of your model.

    0 讨论(0)
提交回复
热议问题