编程教程
您现在的位置: 中国个人站长站 >> 网络编程 >> ASP.NET教程 >> 教程正文 在ASP.NET中实现多文件上传
推荐位

在ASP.NET中实现多文件上传

中国个人站长站 ASP.NET教程 点击数: 更新时间:2007-8-14 4:46:59
  private Boolean SaveFiles()
  {
   //得到File表单元素
   HttpFileCollection files = HttpContext.Current.Request.Files;
   try
   {
    for(int intCount= 0; intCount< files.Count; intCount++)
    {
    
     HttpPostedFile postedFile = files[intCount];
     string fileName, fileExtension;
     //获得文件名字
     fileName = System.IO.Path.GetFileName(postedFile.FileName);
     if (fileName != "")
     {
      //获得文件名扩展
      fileExtension = System.IO.Path.GetExtension(fileName);
      //可根据不同的扩展名字,保存文件到不同的文件夹
      
//注意:可能要修改你的文件夹的匿名写入权限。
      postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("upFiles/") + fileName);
     }
    }
    return true;
   }
   catch(System.Exception Ex)
   {
    return false;
   }
  }
 

教程录入:swh    责任编辑:swh 
个人站长站与你风雨同舟!
本站所提供的资源均来源于互联网,如有侵权行为,请与本站管理员联系,我们会第一时间删除!
·如果您发现《在ASP.NET中实现多文件上传》文章有错误,也请通知我们修改!
联系邮箱chinageren#126.com,谢谢支持!
站内搜索:
广告服务 | 友情链接 | 联系我们 | 免责声明 | 用户留言 | 网站导航
版权所有:中国个人站长站 2007-2008 未经授权禁止复制或建立镜像 客服QQ号:112731235
copyright © 2007-2008 www.ChinaGeRen.com online services. all rights reserved. 苏ICP备05000059号