开发者

Posting a form with a file attachment to a monorail controller

I have the following form (in brail):

<form method="post" enctype="multipart/form-data" action="${UrlHelper.For({@action:'Upload'})}">
<p><b>Select Template:</b> &nbsp;
  <select id="template">
        <option selected>Select One..</option>
        <option value="Research">Research</option>
    </select>
</p>
<br/>
<p><b>Download Worksheet:</b> &nbsp; <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>

Which posts to the following method signature on my controller:

[AccessibleThrough(Verb.Post)]
public UploadResults Upload(string template, [HttpPostedFileAdapterBinder] IHttpPostedFileAdapter file) {}

When I post the form, I only get the file. The template var is null and I am not sure why. Does anyone see somethi开发者_运维技巧ng obvious I am missing?


You're missing the name attribute on the <select>:

<select name="template" id="template">
...
</select>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜