title: How to upload file via ajax
body: <p>I have file upload which doesn't use form to upload the file instead I want to upload it using ajax. I tried the following approach but I cannot pass the file. It's null. Please help. Below is my implementation.</p>
  
  <p><strong>HTML and jQuery function</strong></p>
  
  <pre><code>&lt;div id="Upload"&gt;
      &lt;input type="file" accept="application/x-shockwave-flash" id="virtualtourfile" enctype="multipart/form-data"/&gt;
      &lt;input type="button" value="Upload" id="btnUpload"/&gt;
  &lt;/div&gt;
  
  $('#btnUpload').click(function () {
              $.ajax({
                  url: "uploadvideo",
                  type:'POST',
                  data: $("#virtualtourfile:file"),
                  success: function (data) {
  
                  }
              });
          });
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult UploadVideo(HttpPostedFileBase file)
          {
              return Json("", JsonRequestBehavior.AllowGet);
          }
  </code></pre>