HTMLInputElement: multiple プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

HTMLInputElement.multiple プロパティは、入力フィールドが複数の値を持つことができるかどうかを示します。 Firefox では、 multiple<input type="file"> でのみ対応しています。

論理値です。

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
# dom-input-multiple

ブラウザーの互換性

関連情報