Codectionary / Developer documentation / HTML

Selecting Files with accept and multiple

A file input asks the user to choose local files. accept filters or hints the chooser’s file types, and multiple permits more than one selection. Neither guarantees file content or safety. Browsers intentionally do not let a page silently select arbitrary files from a visitor’s disk.

Syntax

<input type="file" accept="image/png,image/jpeg" multiple>
input.files

Examples

Selecting Files with accept and multiple: working example

Save as an HTML file and open it in a browser. Expected result: Choosing files lists each selected filename and its size in bytes without uploading anything.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Working example</title>
</head>
<body>
<label>Choose PNG or JPEG images <input id="files" type="file" accept="image/png,image/jpeg" multiple></label>
<ul id="list"></ul>
<script>
document.querySelector("#files").addEventListener("change", event => {
  const list = document.querySelector("#list");
  list.replaceChildren();
  for (const file of event.target.files) {
    const item = document.createElement("li");
    item.textContent = `${file.name}: ${file.size} bytes`;
    list.append(item);
  }
});
</script>
</body>
</html>
  1. Expected result: Choosing files lists each selected filename and its size in bytes without uploading anything.
  2. The files property contains File objects supplied through user selection.
  3. textContent safely displays filenames as text.

Best practices

  • Validate size, format, and content on the server when uploading.
  • Use multipart/form-data for an ordinary form upload containing file controls.

Browser compatibility

Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.

Chooser filters are hints. Browser support does not validate selected file contents.

<input> type="file"

Desktop

Chrome
Supported
From 1
Firefox
Supported
From 1
Safari
Supported
From 1
Edge
Supported
From 12
Opera
Supported
From 11

Mobile

Safari on iOS
Supported
From 1
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 1

Firefox

  • From 1 · You can set as well as get the value of HTMLInputElement.files in all modern browsers; this was most recently added to Firefox, in version 57 (see bug 1384030).

Safari

  • From 1

Edge

  • From 12

Opera

  • From 11

Safari on iOS

  • From 1

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0
<input> accept

Desktop

Chrome
Supported
From 1
Firefox
Supported
From 1
Safari
Supported
From 1
Edge
Supported
From 12
Opera
Supported
By 12.1 (possibly earlier)

Mobile

Safari on iOS
Supported
From 1
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 1

Firefox

  • From 1

Safari

  • From 1

Edge

  • From 12

Opera

  • By 12.1 (possibly earlier)

Safari on iOS

  • From 1 · Does not support audio/* MIME type. See bug 242110.

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0
<input> multiple

Desktop

Chrome
Supported
From 2
Firefox
Supported
From 3.6
Safari
Supported
From 4
Edge
Supported
From 12
Opera
Supported
By 12.1 (possibly earlier)

Mobile

Safari on iOS
Supported
From 3.2
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 2

Firefox

  • From 3.6

Safari

  • From 4

Edge

  • From 12

Opera

  • By 12.1 (possibly earlier)

Safari on iOS

  • From 3.2

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0
HTMLInputElement.files

Desktop

Chrome
Supported
From 2
Firefox
Supported
From 3
Safari
Supported
From 4
Edge
Supported
From 12
Opera
Supported
By 12.1 (possibly earlier)

Mobile

Safari on iOS
Supported
From 3
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 2

Firefox

  • From 3

Safari

  • From 4

Edge

  • From 12

Opera

  • By 12.1 (possibly earlier)

Safari on iOS

  • From 3

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0

MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.

HTML Living Standard

Specifications & further reading