当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 在ASP.NET中实现多文件上传

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

点击次数:31 次 发布日期:2008-11-21 22:11:34 作者:源代码网
源代码网推荐

源代码网整理以下一下为代码片段:

源代码网整理以下

源代码网整理以下
privateBooleanSaveFiles()
{
//得到File表单元素
HttpFileCollectionfiles=HttpContext.Current.Request.Files;
try
{
for(intintCount=0;intCount<files.Count;intCount++)
{

HttpPostedFilepostedFile=files[intCount];
stringfileName,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);
}
}
returntrue;
}
catch(System.ExceptionEx)
{
returnfalse;
}
}

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华