国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ASP.NET使用FileUpload上傳文件

2019-11-17 02:06:25
字體:
來源:轉載
供稿:網友

asp.net使用FileUpload上傳文件

前臺代碼:

Html代碼收藏代碼
  1. <asp:FileUploadID="fuKeleyi"runat="server"/>
  2. <asp:ButtonID="BtnUp"runat="server"onclick="BtnUp_Click"Text="上傳"/>
  3. <asp:LabelID="LabMsg"runat="server"></asp:Label>

后臺C#代碼:

C#代碼收藏代碼
  1. usingSystem;
  2. usingSystem.Collections.Generic;
  3. usingSystem.Web;
  4. usingSystem.Web.UI;
  5. usingSystem.Web.UI.WebControls;
  6. namespacedocnet
  7. {
  8. publicpartialclassup:System.Web.UI.Page
  9. {
  10. PRotectedvoidPage_Load(objectsender,EventArgse)
  11. {
  12. }
  13. protectedvoidBtnUp_Click(objectsender,EventArgse)
  14. {
  15. if(fuKeleyi.HasFile)
  16. {
  17. stringsavePath=Server.MapPath("~/hovertreeupload/");//指定上傳文件在服務器上的保存路徑
  18. //檢查服務器上是否存在這個物理路徑,如果不存在則創建
  19. if(!System.IO.Directory.Exists(savePath))
  20. {
  21. System.IO.Directory.CreateDirectory(savePath);
  22. }
  23. savePath=savePath+"http://"+fuKeleyi.FileName;
  24. fuKeleyi.SaveAs(savePath);
  25. LabMsg.Text=string.Format("<ahref='hovertreeupload/{0}'>hovertreeupload/{0}</a>",fuKeleyi.FileName);
  26. }
  27. else
  28. {
  29. LabMsg.Text="你還沒有選擇上傳文件!";
  30. }
  31. }
  32. }
  33. }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武乡县| 淳安县| 临汾市| 大同县| 昌图县| 长兴县| 武义县| 云南省| 屏南县| 靖宇县| 昆明市| 永平县| 安平县| 建宁县| 乐都县| 科尔| 宁河县| 宁都县| 三河市| 胶南市| 彰化县| 兴义市| 兴国县| 金昌市| 手游| 治县。| 和硕县| 霍邱县| 雅江县| 伊川县| 名山县| 麟游县| 同德县| 天气| 东城区| 缙云县| 秦安县| 获嘉县| 泽库县| 东港市| 红安县|