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...
}
}
ここで、(ファイルの種類を選択するための) ドロップダウン ボックスを追加し、その値をファイルと共にコントローラーに送信します。どうすればそれを行うことができますか (ファイルと一緒に他のフォームデータを送信します)?