Javascript examples for DOM HTML Element:Input FileUpload
The accept property sets or gets the accept attribute of the file upload button, which identifies the types of files that the server accepts.
Set the accept property with the following Values
P: Tip: To specify more than one value, separate the values with a comma. |
---|
Value | Description |
---|---|
audio/* | All sound files are accepted |
video/* | All video files are accepted |
image/* | All image files are accepted |
MIME_type | A valid MIME type, with no parameters. |
A String, containing a comma-separated list of accepted content types
The following code shows how to change the accepted content type:
<!DOCTYPE html> <html> <body> Select a file to upload: <input type="file" id="myFile" size="50" accept="image/*"> <button onclick="myFunction()">Change accepted file types</button> <p id="demo"></p> <script> function myFunction() {/*from w ww.j a v a2 s . c om*/ document.getElementById("myFile").accept = "audio/*"; document.getElementById("demo").innerHTML = "changed."; } </script> </body> </html>