如何上传多个文件? [英] how to upload multiple files ?

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

问题描述

嗨 先生,我正在尝试在asp.net中上传多个文件.我用谷歌搜索,但是我发现只有Flash控件或客户端必须选择每个文件(一次选择一个文件),

因此,我还有其他方法可以执行此操作,也可以选择多个文件的任何控件,或者任何提示/建议
请帮助....
谢谢u

解决方案

看看这篇CodeProject文章. 使用进度条使用Flash和ASP.NET进行多个文件上传 [


hi sir i am trying to upload multiple files in asp.net. I google about this but i find only flash controls or client have to select each file(one file at once),

so, is there anything else I can do about this or any control which can select multiple files, or any hint/advise
plzz help....
thank u

Take a look at this CodeProject article. Multiple File Upload With Progress Bar Using Flash and ASP.NET[^]

Good luck.


You can place multiple Upload controls on a page.

There are other examples, not using Flash or Silverlight, you just need to look a little harder.


In ASP.NET you can you this piece of code. This will solve your issue and you can upload multiple files

C#
 
protected void btnUpload_Click(object sender, EventArgs e)
 
{
 
        try
 
        {
 
            // Get the HttpFileCollection
 
            HttpFileCollection hfc = Request.Files;
 
            for (int i = 0; i < hfc.Count; i++)
 
            {
 
                HttpPostedFile hpf = hfc[i];               

                if (hpf.ContentLength > 0)
 
                {
 
                    hpf.SaveAs(Server.MapPath("MyFiles") + "\\" +
 
                      Path.GetFileName(hpf.FileName));                       

                }               

            }    

        }
 
        catch (Exception ex)
 
        {
 
            // Handle your exception here
 
        }
 
 
 
}


这篇关于如何上传多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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