title: Select multiple file to upload as populated in html table
body: <p>I want to find the number of the file selected as file selection tag is populated in an HTML table every row with a button. 
  I just want to find out the file count (total selected files) when clicking on same row button and upload all selected files</p>
  
  <p>The following code gives an error.</p>
  
  <blockquote>
    <p>"Uncaught TypeError: Cannot read property 'length' of undefined"</p>
  </blockquote>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function saveValue(data) {
    var fileU = $(data).closest('tr').find('input[type=file]');
    var count = files.length;
    console.log(count);
    for (var i = 0; i &lt; count; i++) {
      var file = fileU[i].files[0];
      console.log(file)
      formData.append("files[]", file);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;td width="10%" align="center" bgcolor=""&gt;
        &lt;p data-placement="top" data-toggle="tooltip" title="Attached Letter"&gt;&lt;input type="file" class='files' name="files[]" multiple&gt;&lt;/p&gt;
      &lt;/td&gt;
      &lt;td width="40%"&gt;&lt;button class="btnSelect" onclick='saveValue(this);'&gt; Count &lt;/button&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>