MDN self-hosted library · e01.org

HTMLInputElement: multiple property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<input id="my-file-input" type="file" multiple />
js
let fileInput = document.getElementById("my-file-input");

if (fileInput.multiple) {
  // Loop fileInput.files
  for (const file of fileInput.files) {
    // Perform action on one file
  }
  // Only one file available
} else {
  let [file] = fileInput.files;
}