title: File Upload logic in View and Controller(MVC3)
body: <p>I want to implement a file uplaod logic in MVC, My view(cshtml) would contain something like this.</p>
  
  <pre><code>&lt;div id="dialog" title="Upload files"&gt;
                 &lt;p&gt;&lt;input type="file" id="fileUpload" name="fileUpload" /&gt; &lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Upload file" /&gt;&lt;/p&gt;
      &lt;% } %&gt;
  &lt;/div&gt;  
  </code></pre>
  
  <p>And my controller would have the logic to save the file.</p>
  
  <pre><code>  [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult FileUpload(HttpPostedFileBase uploadFile)
      {
          if (uploadFile.ContentLength &gt; 0)
          {
              string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"),
                                             Path.GetFileName(uploadFile.FileName));
              uploadFile.SaveAs(filePath);
          }
          return View();
      }
  </code></pre>
  
  <p>How do i link  the click event to trigger this controller? This was just a sample code I got in the net, LEt me know if it isn't right.</p>
  
  <p>Thanks,
  Adarsh</p>