CKTIS / HTML
accept — a file-picker hint
`accept` tells the picker which file formats an `input type="file"` expects; it is not an upload security boundary.
Version: HTML Living Standard
Syntax
<input type="file" accept=".png,image/png" required>Supply comma-separated extensions beginning with a dot, MIME types without parameters, or image/*, audio/*, video/*. For a format, combine its extension and MIME type, for example .png,image/png. Tokens must be distinct under ASCII case-insensitive comparison.
This guides the interface, not inspection of file contents. A name or declared MIME type may be wrong, and a client can send a different file. The server must still check format, size, and storage rules. multiple separately controls how many files may be chosen; required makes selection mandatory.
The example assigns an in-memory text file despite expecting PNG. An empty required field is invalid, but after assignment checkValidity() returns true: accept does not create a file-type validity error.
Examples
<!doctype html><meta charset="utf-8">
<label>Picture <input id="file" type="file" accept=".png,image/png" required></label>
<output id="result"></output>
<script>
const input = document.querySelector('#file');
const emptyValid = input.checkValidity();
const files = new DataTransfer();
files.items.add(new File(['not an image'], 'notes.txt', { type: 'text/plain' }));
input.files = files.files;
document.querySelector('#result').textContent =
'empty=' + emptyValid + '; selected=' + input.files[0].name +
'; valid=' + input.checkValidity();
</script>Result
empty=false; selected=notes.txt; valid=true
The file exists only in memory. The test demonstrates the validation boundary, not the native picker or server security.