我有以下表格(brail):
<form method="post" enctype="multipart/form-data" action="${UrlHelper.For({@action:'Upload'})}">
<p><b>Select Template:</b>
<select id="template">
<option selected>Select One..</option>
<option value="Research">Research</option>
</select>
</p>
<br/>
<p><b>Download Worksheet:</b> <a id="downloadLink">Worksheet</a></p>
<br/>
<p><b>Research Item Upload</b></p>
<fieldset>
<legend>Upload Research Items File</legend>
<label for="file">File</label>
<input type="file" name="file" size="80" accept="application/vnd.ms-excel,application/excel,application/x-msexcel" />
<br />
<input type="submit" value="Upload" />
</fieldset>
</form>
在我的控制器上发布了以下方法签名:
[AccessibleThrough(Verb.Post)]
public UploadResults Upload(string template, [HttpPostedFileAdapterBinder] IHttpPostedFileAdapter file) {}
当我发布表单时,我只收到该文件。模板var为null,我不知道为什么。有没有人看到我遗失的明显事物?
答案 0 :(得分:1)
您错过了name
上的<select>
属性:
<select name="template" id="template">
...
</select>