HTMLInputElement: multiple property

HTMLInputElement.multiple 속성은 입력이 여러 개의 값을 가질 수 있는지 여부를 나타냅니다. 현재 Firefox는 <input type="file">에 대해서만 multiple을 지원합니다.

불리언 값입니다.

예제

js
// fileInput 은 <input type=file multiple> 입니다.
let fileInput = document.getElementById("myfileinput");

if (fileInput.multiple) {
  // fileInput.files를 순회합니다.
  for (const file of fileInput.files) {
    // 하나의 파일에 대한 작업을 수행합니다.
  }
  // 파일이 하나만 있는 경우
} else {
  let [file] = fileInput.files;
}

명세서

Specification
HTML Standard
# dom-input-multiple

브라우저 호환성

BCD tables only load in the browser

같이 보기