title: Javascript Add multiple file inputs
body: <p>I have a form and file input. I want to select images from another folder.</p>
  
  <pre><code>echo '&lt;pre&gt;';
  var_dump($_FILES);
  echo '&lt;/pre&gt;';
  </code></pre>
  
  <p>When I send my form I need to see all selected images but I see only the last selected.</p>
  
  <p>For example, the first time I select 2 files. After selecting 5 files and submitting  my form I see only the last selected files, but I need to send all 7 files. Is it possible??</p>
  
  <pre><code>&lt;form action="" method="POST" enctype="multipart/form-data"&gt;
      &lt;input type="file" id="sell-images" name="images[]" multiple&gt;
  
      &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have this function for file counter:</p>
  
  <pre><code>    $.fn.fileUploader = function (filesToUpload, sectionIdentifier) {
      var fileIdCounter = 0;
  
      this.closest("#sell-images").change(function (evt) {
          var output = [];
          for (var i = 0; i &lt; evt.target.files.length; i++) {
              fileIdCounter++;
              var file = evt.target.files[i];
              var fileId = sectionIdentifier + fileIdCounter;
  
              filesToUpload.push({
                  id: fileId,
                  file: file
              });
          };
  
          for(var z = 0; z &lt; filesToUpload.length; z++)
          {
              evt.target.files[z] = filesToUpload[z]['file'];
          }
          console.log(evt.target.files)
      });
  
      return this;
  };
  </code></pre>
  
  <p>Here is my onchange function:</p>
  
  <pre><code>$(document).ready(function() {
    var filesToUpload = [];
    var files1Uploader = $("#sell-images").fileUploader(filesToUpload, "images[]");
  
    $("#sell-images").on('change',function(e) {
      e.preventDefault();
  </code></pre>
  
  <p>Here I see in console all selected files from another folder</p>
  
  <pre><code>    console.log($("#sell-images")[0].files);
  
      var formData = new FormData();
  
      for (var i = 0, len = filesToUpload.length; i &lt; len; i++) {
        formData.append("files", filesToUpload[i].file);
      }
    });
  });
  </code></pre>
  
  <p>Here I have all selected files, but when I want to select a new file and send post in my PHP file, the global variable <code>$_FILES</code> shows me only the last selected files. </p>
  
  <p>How can I send my all selected files?</p>
  
  <p>I can do it with another technique every time when selecting a file with JavaScript hide that input and create new but I don't want that.</p>