title: form submit with ajax including file upload Asp.net
body: <p>I am trying to submit a form using ajax. Form contains text fields and a file upload field. The problem is that it submits the text but it does not submit files. my form is </p>
  
  <pre><code>&lt;form onsubmit ="return save();"  id="postadform" enctype="multipart/form-data"&gt;
  Name&lt;input type ="text" name ="name" /&gt;
  Upload image &lt;input type="file" name="image" id ="filee"/&gt;
  &lt;input type ="submit" value = "submit" /&gt;
  &lt;/form&gt;
  
  &lt;script src="~/Scripts/jquery-1.7.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function save() {
              $.ajax({
                  type: 'POST', url: '/Home/saveData', data: $('#postadform').serialize(),enctype:"multipart/form-data",
                  success: function (x) {
                     //do what ever you want
                  },
                  error: function () {
                      alert('There is some error, plz try again!');
                  }
              });
  
              return false;
          }
  
          &lt;/script&gt;
  </code></pre>
  
  <p>And this is part of the HomeController.cs file:</p>
  
  <pre><code>[HttpPost]
  public String saveData()
  {
      String name = Request["name"];
      String filename =  Request.Files[0].FileName; //Problem in this line.  
  
      return "Successful";
  }
  </code></pre>