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>