<form name="myForm" action="http://www.PuStudy.Com/resources/html-forms-action.html"> <input type="file" name="myFile" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"> <button>Submit</button> </form>
The above example demonstrates usage of the
<input> element with the
accept attribute allows you to specify the file types that will be accepted when using a file upload control. When using
type="file" to allow the user to upload a file to the server, the
accept attribute allows you to restrict the file types that they can upload. Any file type that is not specified will not be accepted.
When using this attribute, provide a comma-separated list of content types that the server accepts.
It's best to specify both the MIME type as well as any extensions that might be used.
Here are the values you can use with the