首页 > Web开发 > 详细

最简单的上传文件

时间:2015-03-19 00:30:41      阅读:326      评论:0      收藏:0      [点我收藏+]

前台

技术分享
1       <div class="upload">
2           <asp:FileUpload ID="FileUpload1" runat="server"/>
3           <asp:Button ID="BtnLoad" runat="server" Text="上传" onclick="BtnLoad_Click"/>
4      </div>
View Code

后台

技术分享
 1   protected void BtnLoad_Click(object sender, EventArgs e)
 2         {
 3             if (this.FileUpload1.FileName == "")
 4             {
 5                 Response.Write("<script>alert(‘没有上传文件‘)</script>");
 6                 return;
 7             }
 8             DataAccess.dataDR datadr = new dataDR();
 9             datadr.delete("delete from dbo.autozhesuanxisubiao");
10             string fileName = DateTime.Now.ToString("yyMMddhhmmss") + ".xls";
11             string path = Server.MapPath("~/upload/excel/") + fileName;
12             FileUpload1.SaveAs(path);
13 
14             if (path != null)
15             {
16                 DataAccess.LoadSourceToDataAccess.loadAutoZhesSuangXiShu(path);
17                 Response.Write("<script>alert(‘上传成功!‘)</script>");
18             }
19             else
20             {
21                 Response.Write("<script>alert(‘没有上传文件‘)</script>");
22             }
23         }
View Code

 

最简单的上传文件

原文:http://www.cnblogs.com/yuanjiehot/p/4349057.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!