国产探花免费观看_亚洲丰满少妇自慰呻吟_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. }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 霍州市| 马山县| 吉木萨尔县| 山东省| 九龙城区| 含山县| 渝中区| 福泉市| 西充县| 岱山县| 会东县| 保亭| 大洼县| 嵊泗县| 汕尾市| 英德市| 新乡市| 阿克苏市| 台中县| 佛坪县| 灵宝市| 金寨县| 东乡族自治县| 衡南县| 蓝山县| 镇安县| 德兴市| 扶沟县| 天全县| 阿图什市| 阜平县| 靖江市| 武鸣县| 揭西县| 上林县| 克东县| 恩平市| 调兵山市| 屏东县| 汨罗市| 保德县|