盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

在ASP.NET中完成多文件上传

时间:2024/11/20作者:未知来源:盾怪网教程人气:

[摘要]private Boolean SaveFiles() //得到File表单元素 HttpFileCollection files = HttpContext.Current.Reque...
  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;
   }
  }

关键词:在ASP.NET中完成多文件上传




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版