Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you have a route defined for this custom url:</p> <pre><code>routes.MapRoute( "Upload", "person/{uniqueid}/files", new { controller = "Upload", action = "UploadFile" } ); </code></pre> <p>you just need to give your file input a name:</p> <pre><code>&lt;div&gt;&lt;input id="fileUpload" type="file" name="file" /&gt;&lt;/div&gt; </code></pre> <p>Also I would recommend you to use action arguments instead of looping through <code>Request.Files</code>:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult UploadFile(int uniqueID, HttpPostedFileBase file) { return View(); } </code></pre> <p>and if you wanted to post multiple files:</p> <pre><code>&lt;div&gt;&lt;input type="file" name="files" /&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="file" name="files" /&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="file" name="files" /&gt;&lt;/div&gt; ... </code></pre> <p>use a collection:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult UploadFile(int uniqueID, IEnumerable&lt;HttpPostedFileBase&gt; files) { return View(); } </code></pre> <p>You might also find the <a href="http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx" rel="nofollow">following blog post</a> useful.</p> <p>Or even better, use a view model:</p> <pre><code>public class MyViewModel { public int UniqueID { get; set; } public IEnumerable&lt;HttpPostedFileBase&gt; Files { get; set; } } </code></pre> <p>and then:</p> <pre><code>[AcceptVerbs(HttpVerbs.Post)] public ActionResult UploadFile(MyViewModel model) { return View(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload