input accept Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:input

Description

The accept attribute sets the types of files that the server accepts via a file upload.

The accept attribute can only be used with <input type="file">.

Syntax

To specify more than one value, separate the values with a comma, for example <input accept="audio/*,video/*,image/*" />.

Attribute Values

Value Description
file_extension A file extension starting with the STOP character, e.g: .gif, .jpg, .png, .doc
audio/*All sound files are accepted
video/*All video files are accepted
image/*All image files are accepted
media_type A valid media type, with no parameters. Look at IANA Media Types for a complete list of standard media types

Specify that the server accepts only image files in the file upload:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form><!--   w ww .ja  v a2s . co  m-->

</body>
</html>

Related Tutorials