在ASP.NET中实现多文件上传[转]
2010-03-17 10:37
351 查看
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;
}
}
{
//得到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中实现多文件上传-孟宪会
- Asp.net 2.0 用 FileUpload 控件实现多文件上传 用户控件(示例代码下载)
- 为ASP.NET MVC开发一些常用插件(二)—— 实现无刷新文件上传
- iOS开发之结合asp.net webservice实现文件上传下载
- 在ASP.NET中实现多文件上传
- Asp.Net实现无刷新文件上传并显示进度条(非服务器控件实现)
- [Fine Uploader] 用Fine Uploader+ASP.NET MVC实现ajax文件上传[代码示例]
- asp.net实现大文件上传
- 在ASP.NET MVC中实现大文件异步上传(1)
- ASP.NET上传下载文件示例,使用webClient实现
- asp.net mvc实现上传文件
- asp.net实现ftp上传代码(解决大文件上传问题)
- ASP.NET 2.0(C#)实现多文件上传
- asp.net实现ftp上传代码(解决大文件上传问题)
- asp.net web实现ftp上传代码 (解决大文件上传问题)
- 在ASP.NET中实现多文件上传
- JQuery多文件上传插件Uploadify在ASP.NET中的实现
- 在ASP.NET中实现多文件上传
- 关于jQuery在Asp.Net Mvc 框架下Ajax文件上传的实现
- C# asp.net实现文件上传