如何在Asp.Net Mvc中上传多个文件?请查看我的代码 [英] How Do I Upload Multiple Files In Asp.Net Mvc? Please View My Code Behind

查看:58
本文介绍了如何在Asp.Net Mvc中上传多个文件?请查看我的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

try
        {
            HttpFileCollection hfc = Request.Files;
            for (int i = 0; i < hfc.Count; i++)
            {
                HttpPostedFile hpf = hfc[i];
                if (hpf.ContentLength > 0)
                {                        
                    hpf.SaveAs(Server.MapPath("~/uploads/") +System.IO.Path.GetFileName(hpf.FileName);                        
                }
            }
        }
        catch (Exception)
        {
            
            throw;
        }

推荐答案

谷歌多文件上传mvc,你会发现很多完整的例子。更有可能是你没有发布的代码是问题(你不能使用ajax上传文件,在更新中)面板,来自不支持多次上传的浏览器等等。)
Google "multiple file upload mvc" and you'll find lots of complete examples. It is more likely to be code you haven't posted that is the issue (you can't upload files using ajax, in an update panel, from browsers that don't support multiple uploads etc etc etc).


这篇关于如何在Asp.Net Mvc中上传多个文件?请查看我的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆