title: How to append multiple files into formdata using jquery
body: <p>I am using a input type file with multiple attribute. I want to save the files into a folder. But i am not sure how to append multiple files. Help will be greatly appreciated.</p>
  
  <p>Script</p>
  
  <pre><code>$(document).on('click', '.btnSubmit', function () {
       var data = new FormData();
          var files = $('[type="file"]').get(0).files;
  
          if (files.length &gt; 0) {
           _.each(files, function (program, idx) {
                  data.append("file", program);
              });
          }
          _appFun._ajaxcall({
                  type: "POST",
                  url: '/application/test/saveFiles',
                  type: 'POST',
                  data: data,
                  cache: false,
                  contentType: false,
                  processData: false,
                  success: function (data) {
                      //show content
                      alert('Success!')
                  }
             });
  });
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>[HttpPost]
      public ActionResult saveFiles()
      {
  
          string directory = AppSettings.Application.uploadFolder;
  
  
          HttpPostedFileBase file = Request.Files["file"];
  
          if (file != null &amp;&amp; file.ContentLength &gt; 0)
          {
              var fileName = Path.GetFileNameWithoutExtension(file.FileName);
  
              string extension = Path.GetExtension(file.FileName);
  
              var randomId = uniqId();
  
              file.SaveAs(Path.Combine(directory, fileName + randomId + extension));
          }
          return RedirectToAction("Index");
      }
  </code></pre>