davidkomer
davidkomer

Reputation: 3088

Custom mime type for input element

According to the spec at https://www.w3.org/wiki/HTML/Elements/input/file

The "accept" attribute is a series of MIME types.

In this case (i.e. the file is not coming from a server), is it possible to set a custom MIME type for a certain file extension or binary file peeking (e.g. some procedure to read the header)?

Upvotes: 0

Views: 2178

Answers (1)

jburtondev
jburtondev

Reputation: 3263

Yes, you can set custom MIME types.

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

To use this, use the following <input type="file" name="example" accept= "your-custom-extension-1, your-custom-extension-2, your-custom-extension-3">

In addition, read the following statement about the accept attribute: "If the value of the type attribute is file, then this attribute will indicate the types of files that the server accepts, otherwise it will be ignored".

Upvotes: 2

Related Questions