【问题标题】:Upload many file to Many Model properties in a single page将多个文件上传到单个页面中的多个模型属性
【发布时间】:2013-08-27 08:16:39
【问题描述】:

我必须在视图中填写以下模型:

IEnumerable<File> Photos
IEnumerable<File> Logos
IEnumerable<File> Videos

如何通过一个 POST 将多个文件发送到控制器操作?

【问题讨论】:

    标签: c# asp.net-mvc-4 post file-upload


    【解决方案1】:

    这个呢:

        [HttpPost]
        public ActionResult Post(Class Model, IEnumerable<HttpPostedFileBase> Photos, IEnumerable<HttpPostedFileBase> Logos, IEnumerable<HttpPostedFileBase> Videos)
        { 
            // proceed 
        }
    

    照片、徽标和视频应在哪里为您的控件命名(输入类型文件)

    【讨论】:

    • 那么,模型的其余部分呢?如何发布模型的其他属性?我可以避免将它们全部作为 Action 参数吗?
    猜你喜欢
    • 2013-10-12
    • 2014-07-12
    • 2017-11-17
    • 1970-01-01
    • 2021-07-30
    • 2014-10-31
    • 1970-01-01
    • 2022-01-25
    • 1970-01-01
    相关资源
    最近更新 更多