HTML Attributes
HTML <input> accept Attribute
The accept attribute hints which file types a file-upload input should allow the user to pick.
The <input> accept Attribute
The accept attribute is used with <input type="file"> to tell the browser which kinds of files the user is expected to upload. Browsers use it to filter the file picker, so users mostly see matching files. It is only a hint, not a security guarantee.
Syntax
ℹ️
Syntax: <input type="file" accept="value">, where value is a comma-separated list of file-type specifiers: file extensions (.pdf), MIME types (image/png) or wildcard MIME types (image/*).
<label for="resume">Upload your resume</label>
<input type="file" id="resume" name="resume"
accept=".pdf,.doc,.docx,application/pdf">| Value | Description |
|---|---|
| .ext | A filename extension beginning with a dot, e.g. .pdf or .jpg |
| image/* | Any image file (wildcard MIME type) |
| audio/* | Any audio file |
| video/* | Any video file |
| image/png | A specific MIME type such as PNG images |
| .jpg,.png | A comma-separated list combining multiple specifiers |
⚠️
accept only filters the picker for convenience. Users can still bypass it, so always validate uploaded file types and sizes on the server.
