HTML5: How to specify the types of files that the server accepts?
Solution:
HTML Code:
Explanation:
- This HTML code demonstrates how to create a form with an input field that allows users to select image files.
- The form is configured with the method attribute set to "POST" and the action attribute set to the URL where the form data will be submitted.
- Within the form, there is an input field of type "file" (<input type="file">) named "my_image".
- The accept attribute specifies the types of files that the server accepts. In this case, it is set to "image/*", indicating that only image files are allowed.
- Additionally, there is a submit button (<input type="submit">) to submit the form data.
Live Demo:
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics