HTML <form> with accept Attribute

You are Here:

HTML <form> with accept Attribute

The accept attribute specifies a comma-separated list of file types that the server accepts.

Note: When receiving any data from the user, it is necessary to validate on the server before saving it to the database.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-image.php" accept="image/*"> <input type="file" name="myImg"> <input type="submit" value="Submit"> </form> </body> </html>

Attribute Value

ValueExplanation
.png, .jpg, .doc, .txtSpecifies a particular file.
text/htmlSpecifies a MIME type. Extension is not necessary.
audio/*Specifies a audio file.
video/*Specifies a video file.
image/*Specifies a image file.

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author