
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input FileUpload accept Property
The HTML DOM Input FileUpload accept property returns a string, which is the value of the accept attribute of FileUpload. User can also set it to a new value.
Syntax
Following is the syntax −
- Returning string value
inputFileUploadObject.accept
- Setting value attribute to a string value
inputFileUploadObject.accept = value
Example
Let us see an example of Input FileUpload accept property −
<!DOCTYPE html> <html> <head> <title>Input FileUpload accept</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"]{ border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>FileUpload-accept</legend> <label for="FileSelect">Upload: <input type="file" id="FileSelect"> </label><br> <input type="button" onclick="fileAccept('Audio')" value="Audio"> <input type="button" onclick="fileAccept('Image')" value="Image"><br> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputFile = document.getElementById("FileSelect"); divDisplay.textContent = 'All Files Accepted'; function fileAccept(fileType) { if(fileType === 'Audio'){ inputFile.accept = 'audio/*'; divDisplay.textContent = 'Only '+inputFile.accept+' Files'; } else { inputFile.accept = 'image/*'; divDisplay.textContent = 'Only '+inputFile.accept+' Files'; } } </script> </body> </html>
Output
This will produce the following output −
After Clicking ‘Audio’ button −
After clicking ‘Image’ button −
- Related Articles
- HTML DOM Input FileUpload disabled Property
- HTML DOM Input FileUpload files Property
- HTML DOM Input FileUpload name Property
- HTML DOM Input FileUpload form Property
- HTML DOM Input FileUpload value Property
- HTML DOM Input FileUpload required Property
- HTML DOM Input FileUpload type Property
- HTML DOM Input FileUpload autofocus Property
- HTML DOM Input FileUpload Object
- HTML DOM Input Time type Property
- HTML DOM Input Time value Property
- HTML DOM Input URL autocomplete Property
- HTML DOM Input URL autofocus Property
- HTML DOM Input URL defaultValue Property
- HTML DOM Input URL disabled Property

Advertisements