ASP.NET MVC 壹:瀏覽器選擇檔案並上傳到伺服器
阿新 • • 發佈:2021-11-10
- 目的:在網頁上選擇需要的檔案,並上傳到IIS Express伺服器。
- 檔案結構:
- Upload/Index.cshtml程式碼
1 @using (Html.BeginForm("Upload", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" })) 2 { 3 <div style="margin-top: 20px;"> 4 <fieldset id="myfieldset1"> 5 <legend>資訊匯入</legend> 6
./Upload/Index.cshtml - Upload/Upload程式碼
1 public ActionResult Upload(HttpPostedFileBase httpPostedFileBase) 2 { 3 HttpPostedFileBase httpPostedFile = Request.Files["
./Controllers/UploadController.cs