0

我用:

@using (Html.BeginForm("UploadPackage", "Manager"))

将 webForm 数据发送到UploadPackage操作。

现在< input type = "file" />我在该强类型视图中 添加一个类型为 file() 的输入标签。我想要做的是:如何在我的操作中从 webForm(包括文件)获取所有数据并处理它们?

4

1 回答 1

3

视图中的表格:

@using (Html.BeginForm("FileUpload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 
     @Html.ValidationSummary();
     <ol>
     <li class="lifile">
     <input type="file" id="fileToUpload" name="file" />
     <span class="field-validation-error" id="spanfile"></span>
     </li>
     </ol>
     <input type="submit" id="btnSubmit" value="Upload" />
}

在控制器方面:

[HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file)
{
     // Implementation
}
于 2013-08-26T09:44:02.663 回答