当前位置:编程学习 > C#/ASP.NET >>

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

答案: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无组件文件上传,效率的关键
下一个:window.open的参数说明+点击链接窗口的一种漂亮的打开方法

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,