title: Getting uploaded files count as zero while calling the function in controller through Json in mvc4
body: <p>I created multiple file uploader dynamically using javascript within the div FileUploadContainer.while i put  btnSubmit outside the form tag i get Request.Files.Count as zero.I need to call the PopUp() through Json .If i put btnSubmit  inside the form tag
  it does not call the Save() on javascript  and will call PopUp() method on form submit.
  I need to call the PopUp() through Json and need to get the  Request.Files.Count .Pls help.</p>
  
  <pre><code>@using (Html.BeginForm("PopUp", "EnergyCatagory", FormMethod.Post, new { enctype = "multipart/form-data" }))
  { 
      &lt;div id="FixedHeightContainer"&gt;
          &lt;div id="FileUploadContainer"&gt;
          &lt;/div&gt;           
          &lt;input type="button" id="btnAddAttachment" name="btnAddAttachment" class="ZWidgetTitle"
              value="Add More Attachments" onclick="AddFileUpload()" /&gt;
      &lt;/div&gt;
      &lt;div id="NewAttachment"&gt;
          &lt;div style="background-color: #DADADA;"&gt;
              &lt;center&gt;
                  &lt;label style="font-family: Verdana; font-size: 13px; font-weight: bold; color: black;
                      height: 30px; width: 100%; padding-top: 20px;" id="lblMessage"&gt;
                  &lt;/label&gt;
              &lt;/center&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="horizSep"&gt;
      &lt;/div&gt;
        &lt;div id="buttons"&gt;
         &lt;/div&gt;          
  }   &lt;button id="btnSubmit" class="buttons" onclick="Save()"&gt;
          Attach&lt;/button&gt;
   function Save()
  {$.ajax({
              url: '/EnergyCatagory/PopUp',
              type: 'POST',
              contentType: 'application/json;',
              dataType: 'json',
              success: function (result) {
              alert("success");
              }
          });
  </code></pre>
  
  <p>}controller-----</p>
  
  <pre><code>    public ActionResult PopUp()
      {
          for (int i = 0; i &lt; Request.Files.Count; i++)
          {
              HttpPostedFileBase PostedFile = Request.Files[i];
              if (PostedFile.ContentLength &gt; 0)
              {
                  string FileName = System.IO.Path.GetFileName(PostedFile.FileName);
                  var path1 = Path.Combine(Server.MapPath("~/Files/"), FileName);
                  //PostedFile.SaveAs(Server.MapPath("Files\\") + FileName);
                  PostedFile.SaveAs(path1);
         return Json(
             new
             {
                 CustomMessage = "My message",
  
             });
            }
          }
  </code></pre>