在ASP.NET中实现多文件上传 - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 在ASP.NET中实现多文件上传 (http://www.webasp.net/article/26/25710.htm) |
| -- 作者:未知 -- 发布日期: 2005-07-20 |
| 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; } } |
| webasp.net |