Search code examples
htmlgoogle-chromeinputfile-browser

HTML input type="file" too many files in Chrome?


Given this minimal, complete, and verifiable example:

<html>
  <head>
    <script>
      var handleFiles = function(event) {
        console.log('# of files: ' + event.target.files.length);
      };
    </script>
  </head>
  <body>
    <input type="file" onchange="handleFiles(event)" multiple/>
  </body>
</html>

I am not able to select my test case of 1682 files in Chrome (though it works in Firefox). My test case is 316 megabytes, so I slimmed it down to a folder with a similar number of files, but simple text files containing one character. The problem persisted. Is there a problem with Chrome's implementation of handling this control? If so is there a polyfill? How can I select 1682 files in Chrome?


Solution

  • It looks like it's not working because the upload is limited by the total number of characters in all of the file names combined. The limit seems to be about 32K characters.

    See these:

    What is the max number of files to select in an HTML5 [multiple] file input?

    https://bugs.chromium.org/p/chromium/issues/detail?id=44068