Set the types of files that the server accepts in HTML


Use the accept attribute to set the types of files that the server accepts in HTML. Use the attribute only with <input type = "file">.

Example

You can try to run the following code to work with accept attribute −

<!DOCTYPE html>
<html>
   <head>
      <title>File Upload Box</title>
   </head>
   <body>
      <form>
         <input type = "file" name = "fileupload" accept = "image/*" />
      </form>
   </body>
</html>

Updated on: 02-Mar-2020

107 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements