0
我正在嘗試使用jQuery提交表單。該表單包含一個文件上傳輸入,我用this SO method僞裝,並自動使用this SO method提交。當我檢查我的控制器中的_upload
的參數時,type
有一個值,但file
爲空。提交包含類型文件輸入的jQuery表單
我哪裏錯了?
查看:
@using (Html.BeginForm("_upload", "Config", null, FormMethod.Post, new { @id = "form_" + Model.imageType }))
{
<label>
<input id="[email protected]" type="file" name="file" required />
</label>
@Html.Hidden("type",Model.imageType)
}
....
<script>
$(function() {
$('#[email protected]').change(function() {
$('#[email protected]').submit();
})
})
</script>
控制器
[HttpPost]
public void _upload(HttpPostedFileBase file, string imageType)
{
//dostuff
}
感謝,這是我錯過了什麼! – tallpaul