ASP.NET MVC 文件上傳

  若是想要用HTML表單實做文件上傳的功能,那麼必須在輸出的<form>表單標籤加上一個enctype屬性,且內容必須設定爲multipart/form-data,要經過Html.BeginForm輔助方法新增額外的屬性必須再加上第四個參數,並傳入一個匿名對象便可。以下範例:orm

@using (Html.BeginForm("Upload", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
  @Html.TextBox("File1", "", new { type = "file", size = "25" })
  <input type="submit" />
}對象

相關文章
相關標籤/搜索