title: file upload using modal popup in MVC3
body: <p>I am trying to implement file upload using modal popup in MVC3.  When uploading file the controller receives null instead of file name. Can this functionality be achieved in MVC3 .<br>
  jQuery is as follows,</p>
  
  <p>Controller Code:</p>
  
  <p>"</p>
  
  <pre><code>[HttpPost]
          public ActionResult Upload(HttpPostedFileBase file)
          {
  
              var fileName = "";
              var path = "";
              string file1 = "";
              if (ModelState.IsValid)
              {
                  if (file.ContentLength &gt; 0)
                  {
                      fileName = Path.GetFileName(file.FileName);
                      path = Path.Combine(Server.MapPath("~/Content/"), fileName);
                      file.SaveAs(path);
                  }
              }
              return RedirectToAction("Create","Manager",new{file1=fileName});
          }
  </code></pre>
  
  <p>"
  "</p>
  
  <pre><code>    var linkObj;
      $(function () {
          $(".editLink").button();
  
          $('#updateDialog').dialog({
              autoOpen: false,
              width: 400,
              resizable: false,
              modal: true,
              buttons: {
                  "Update": function () {
                      $("#update-message").html(''); //make sure there is nothing on the message before we continue                         
                      $("#updateCarForm").submit();
                  },
                  "Cancel": function () {
                      $(this).dialog("close");
                  }
              }
          });
  
          $(".editLink").click(function () {
              //change the title of the dialgo
              linkObj = $(this);
              var dialogDiv = $('#updateDialog');
              var viewUrl = linkObj.attr('href');
              $.get(viewUrl, function (data) {
                  dialogDiv.html(data);
                  //validation
                  var $form = $("#updateCarForm");
                  // Unbind existing validation
                  $form.unbind();
                  $form.data("validator", null);
                  // Check document for changes
                  $.validator.unobtrusive.parse(document);
                  // Re add validation with changes
                  $form.validate($form.data("unobtrusiveValidation").options);
                  //open dialog
                  dialogDiv.dialog('open');
              });
              return false;
          });
  
      });
  
  
      function updateSuccess() {
          if ($("#update-message").html() == "True") {
              //we update the table's info
              var parent = linkObj.closest("tr");
              parent.find(".carName").html($("#Name").val());
              parent.find(".carDescription").html($("#Description").val());
              //now we can close the dialog
              $('#updateDialog').dialog('close');
              //twitter type notification
              $('#commonMessage').html("Update Complete");
              $('#commonMessage').delay(400).slideDown(400).delay(3000).slideUp(400);
          }
          else {
              $("#update-message").show();
          }
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>"</p>
  
  <p>Script loading file.</p>
  
  <p>"</p>
  
  <pre><code>&lt;% using (Ajax.BeginForm("Upload", "Manager", null,
          new AjaxOptions
          {
              UpdateTargetId = "update-message",
              InsertionMode = InsertionMode.Replace,
              HttpMethod = "POST",
              OnSuccess = "updateSuccess"
          }, new { @id = "updateCarForm" }))
  
      { %&gt; 
      &lt;div class="editor-field" id="error invisible"&gt;&lt;/div&gt;
      &lt;fieldset&gt;
        &lt;div&gt;
          &lt;input type="file" name="file" id="file"/&gt;
  
        &lt;/div&gt;
           &lt;div&gt;   
             &lt;input type="submit"  value="Save" /&gt;
           &lt;/div&gt;
      &lt;/fieldset&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>"</p>