title: How to display multiple files properties using jQuery?
body: <p>I am trying to display the details of multiple uploaded files using jQuery.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;jQuery Multi File Upload&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
         &lt;form id="file_upload" action="" method="get" enctype="multipart/form-data"&gt;
              &lt;p&gt;&lt;input type="file" name="file_1" class="uploadFile"&gt;&lt;/p&gt;
              &lt;p&gt;
                  &lt;input type="submit" value="Upload" id="btnSubmit"&gt;
                  &lt;a id="add_more" href="#"&gt;Add more&lt;/a&gt;
              &lt;/p&gt;
         &lt;/form&gt;                                                      
         &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
         &lt;script&gt;
             $(document).ready(function(){
                  $("#add_more").click(function(){
                      var current_count = $("input[type='file']").length;
                      var next_count = current_count + 1;
                      $("#file_upload").prepend('&lt;p&gt;&lt;input type="file" name="file_'+next_count+'" class="uploadFile" /&gt;&lt;/p&gt;');
                  });
                  $("#btnSubmit").click(function(e){
                      e.preventDefault(); 
                      var file_count = $(".uploadFile").length;
  
                      var file_arr = [];
                      for (var i = 0; i &lt; file_count; i++){
                          // file_arr[i] = $(".uploadFile")[i].files[i];
                          file_arr[i] = $(".uploadFile").prop('files')[i];
                          alert(file_arr[i].name);
                          alert(file_arr[i].size);
                          alert(file_arr[i].type);
                      }
                  });
             });
         &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But the problem is that it is displaying the details of the first uploaded file properly, and gives me error <code>Uncaught TypeError: Cannot read property 'name' of undefined</code> for the 2nd file onward.</p>