Accept Attribute with File extensions

From W3C Wiki
Jump to: navigation, search

Change Proposal


HTML5 defines the accept attribute for the file upload control which allows authors to tell user agents the type of file they would like the end user to upload. With this information, the user agent is able to scope the list of files available for the user to choose from and it is also able to provide unique device dependent experiences such as being able to take a picture with a camera.

The accept attribute is currently defined to allow a comma separated list of three specific string tokens (‘image/*’, ‘video/*’, ‘audio/*’) or a valid mime type. Another common way that authors and end users identify files they wish to choose from is via file extensions. This proposal is about allowing the accept attribute to include file extensions in the comma separated list of values.


The accept attribute is intended to help authors scope the list of files for a user to choose from. The current options available to authors still leave a degree of ambiguity in what file choices users will be shown.

On multiple operating systems, files can’t be filtered by mime type directly, they need to be mapped to file extensions. There are multiple ways to map mime types and the results in different browsers today are different based on how the mapping is done.

There may also be some files types which don’t have a corresponding mime type. The current schema doesn’t allow a web author to filter for those files.

Identifying file types by file extension is common for many developers and for many people may be simpler than identifying files by mime type. Given the objective of the accept attribute, supporting file extensions is a natural fit and something we believe web authors would take advantage of.

Details File Upload state (type=file)

The accept attribute may be specified to provide user agents with a hint of what file types will be accepted.

If specified, the attribute must consist of a set of comma-separated tokens, each of which must be an ASCII case-insensitive match for one of the following:

The string audio/*

Indicates that sound files are accepted.

The string video/*

Indicates that video files are accepted.

The string image/*

Indicates that image files are accepted.

<added text> A valid file extension denoted by a U+002E FULL STOP character (.) followed by a string of characters

Indicates that files with the specified file extension are accepted.

</added text>

A valid MIME type with no parameters

Indicates that files of the specified type are accepted.

The tokens must not be ASCII case-insensitive matches for any of the other tokens (i.e. duplicates are not allowed). To obtain the list of tokens from the attribute, the user agent must split the attribute value on commas. <added text>Tokens that begin with a period should be treated as file extensions, other tokens should be treated as a MIME type.</added text>


Positive Effects

Provide web authors more options for filtering file types using the accept attribute

Negative Effects

File extensions are not supported on some older Mac Operating systems.

Conformance Classes Changes

None identified


None identified