我正在尝试在 MVC 中实现文件上传。我有以下有效的代码。
@using (Html.BeginForm("ActioName", "ControllerName", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div>
<input type="file" name="file" />
<input type="submit" value="OK" class="button" />
</div>
}
[HttpPost]
public ActionResult UploadFile(HttpPostedFileBase file)
{
// Verify that the user selected a file
if (file != null && file.ContentLength > 0)
{
//do something here...
}
}
现在我想添加一个下拉框(以选择文件类型)并将该值与文件一起发送到我的控制器。我该怎么做(连同文件一起发送其他表单数据)?