求完整的上传代码! 由于水平有限,项目比较着急,没时间研究了,想求完整的上传文件代码!谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/du9232/archive/2004/09/05/95349.aspx .aspx页面加个HtmlInputFile控件,id为file1;.aspx.cs文件里file1.PostedFile.SaveAs(filename); 测试通过:System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; try { for(int fileCount = 0;fileCount<files.Count;fileCount++) { //定义访问客户端上传文件的对象 System.Web.HttpPostedFile postedFile = files[fileCount]; // postedFile.SaveAs(Server.MapPath(System.IO.Path.GetExtension(postedFile.FileName))); //这里我自动根据日期为文件命名,确保文件名不重复 string newFileName=System.DateTime.Now.ToString(); newFileName=newFileName.Replace(":",""); newFileName=newFileName.Replace("-",""); newFileName=newFileName.Replace(" ",""); newFileName+=System.IO.Path.GetExtension(postedFile.FileName); postedFile.SaveAs(Server.MapPath(@"../root/"+newFileName)); } } catch(Exception ex) { Response.Write(" <font color='Red' size='2'>'"+ ex.Message +"' </font>;"); } 电脑休眠与启动! csc.exe 占用CPU100%的问题困扰 重金求母版页导航页导航条 默认 划过 点击 三种效果 要通用的 请问我在页面代码文件中为何引用不到页面Formview中的控件? 在编程中遇到问题大家如何解决?(讨论一下) 还是刚才那段代码,如果实现等待时间? 被武汉联想研发中心拒了,郁闷ing。。。散分 Label的Visible属性如何在代码中改变 在DataGrid里插入下拉框 session problem 我现在有了表态IP,国际域名,想把自己的电脑做成服务器,还需要做一些事,具体有哪此步骤,谢谢了, 关于文件下载问题????
HtmlInputFile控件,id为file1;
.aspx.cs文件里
file1.PostedFile.SaveAs(filename);
System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
try
{
for(int fileCount = 0;fileCount<files.Count;fileCount++)
{
//定义访问客户端上传文件的对象
System.Web.HttpPostedFile postedFile = files[fileCount];
// postedFile.SaveAs(Server.MapPath(System.IO.Path.GetExtension(postedFile.FileName)));
//这里我自动根据日期为文件命名,确保文件名不重复
string newFileName=System.DateTime.Now.ToString();
newFileName=newFileName.Replace(":","");
newFileName=newFileName.Replace("-","");
newFileName=newFileName.Replace(" ","");
newFileName+=System.IO.Path.GetExtension(postedFile.FileName); postedFile.SaveAs(Server.MapPath(@"../root/"+newFileName)); }
}
catch(Exception ex)
{
Response.Write(" <font color='Red' size='2'>'"+ ex.Message +"' </font>;");
}