title: List selected files from file input
body: <p>I want to list selected file from file input.</p>
  
  <pre><code>  &lt;div class="fileUpload myButton"&gt;
      &lt;span&gt;Upload&lt;/span&gt;
      &lt;input type="file" name="imageURL[]" id="imageURL" multiple="" class="file" /&gt;
    &lt;/div&gt;
      &lt;div id="file-list"&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>I have this code</p>
  
  <pre><code>(function () {
  var filesUpload = document.getElementById("imageURL"),z
      fileList = document.getElementById("file-list");
  
  function uploadFile (file) {
      var li = document.createElement("li"),
          div = document.createElement("div"),            
          reader,
          xhr,
          fileInfo;
  
      li.appendChild(div);
  
      // Present file info and append it to the list of files
      fileInfo = "&lt;div class=\"neutral\"&gt;File: &lt;strong&gt;" + file.name + "&lt;/strong&gt; with the size &lt;strong&gt;" + parseInt(file.size / 1024, 10) + "&lt;/strong&gt; kb is in queue.&lt;/div&gt;";
      div.innerHTML = fileInfo;
  
      fileList.appendChild(div);
  }
  
  function traverseFiles (files) {
      if (typeof files !== "undefined") {
          for (var i=0, l=files.length; i&lt;l; i++) {
              uploadFile(files[i]);
          }
      }
      else {
          fileList.innerHTML = "&lt;div class=\"neutral\"&gt;Your browser does not support Multiple File Upload, but you can still upload your file. We recommend you to upload to a more modern browser, like &lt;a href=\"http://google.com/chrome\" target=\"_blank\"&gt;Google Chrome&lt;/a&gt; for example.&lt;div&gt;";
      }   
  }
  
  filesUpload.addEventListener("change", function () {
      traverseFiles(this.files);
  }, false);
  
  
       })();
  </code></pre>
  
  <p>But the problem is when the user selects another files it is added to the list but the old files is not uploaded when the form is submitted.</p>
  
  <hr>
  
  <p>Simplified: when the user selects file1.pdf and file2.pdf 
  The list shows file1.pdf and file2.pdf 
  When he selects again another files file3.pdf and file4.pdf
  the list shows file1.pdf , file2.pdf, file3.pdf and file4.pdf 
  But when he submit the form only file3.pdf and file4.pdf is uploaded </p>
  
  <p>My question is how to remove the files which will not be uploaded from the list.
  OR a way to upload all the files in the list.
  Thanks in advance.</p>