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: 2020-03-02T12:35:56+05:30

153 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements