Horje
HTML accept Attribute HTML Input

Definition and Usage

The accept attribute specifies the types of files that the server accepts (that can be submitted through a file upload).

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

Tip: Do not use this attribute as a validation tool. File uploads should be validated on the server.


Applies to

The accept attribute can be used on the following element:

Element Attribute
<input> accept

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


How to Specify that the server accepts only image files in the file upload

The input accept attribute. Note: Because of security issues, this example will not allow you to upload files.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The input accept attribute</h1>

<form action="/action_page.php">
  <label for="img">Select image:</label>
  <input type="file" id="img" name="img" accept="image/*">
  <input type="submit">
</form>

<p><strong>Note:</strong> Because of security issues, this example will not allow you to upload files.</p>

</body>
</html>

Output should be:

How to Specify that the server accepts only image files in the file upload




html accept

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://horje.com/learn/1434/reference