title: Upload file using Ajax call using ASP.NET MVC
body: <p>I would like to upload a file in my page using:</p>
  
  <pre><code>&lt;input type="file" name="FileName"&gt;
  </code></pre>
  
  <p>I have a button, clicking on which an ajax post is done.</p>
  
  <pre><code>$.ajax({
             cache: false,
             async: true,
             type: "POST",
             url: '@Url.Content("~/OCR/OCRProcessor")',
             data: '',
             success: function (data) {
                 $('#ocrresult').val(data);
             }
         });
  </code></pre>
  
  <p>I would like to get the file uploaded in the controller action method something like below:</p>
  
  <pre><code>HttpPostedFileBase hpf = Request.Files["FileName"] as HttpPostedFileBase 
  </code></pre>
  
  <p>Please let me know the <strong>optimal way</strong> to achieve this task.</p>