Change the accepted content type:
The accept property sets or returns the value of the accept attribute of the file upload button.
The accept attribute specifies the types of files that the server accepts (that can be submitted through a file upload).
The accept property is supported in all major browsers! However, Safari and Internet Explorer 9 (and earlier versions) do not filter out the proper file types when the user browse for files.
Return the accept property:
Set the accept property:
Tip: To specify more than one value, separate the values with a comma.
Value | Description |
---|---|
audio/* | All sound files are accepted |
video/* | All video files are accepted |
image/* | All image files are accepted |
MIME_type | A valid MIME type, with no parameters. Look at IANA MIME types for a complete list of standard MIME types |
Return Value: | A String, containing a comma-separated list of accepted content types |
---|
Display the accepted content type of a <input type="file"> element:
The result of x could be:
Accept multiple content types:
HTML reference: HTML <input> accept attribute