
- 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 files Property
The HTML DOM FileUpload files property returns a FileList object which contains all the files that are selected by the file upload button.
Syntax
Following is the syntax −
object.files
Example
Let us see an example of FileUpload files property −
<!DOCTYPE html> <html> <head> <style> body{ text-align:center; background-color:#52B2CF; color:#fff; } .btn{ background-color:coral; border:none; height:2rem; border-radius:50px; width:60%; margin:1rem auto; display:block; color:#fff; outline:none; } .show{ font-size:1.2rem; color:#fff; font-weight:bold; } </style> </head> <body> <h1>DOM FileUpload files Property Example</h1> <p>Select some files</p> <input type="file" class="file-upload-btn" multiple> <button onclick = "showFiles()" class = "btn">Click me to see all selected file</button> <div class="show"></div> <script> function showFiles() { var fileBtn = document.querySelector(".file-upload-btn"); var showMsg = document.querySelector(".show"); showMsg.innerHTML=''; if(fileBtn.files.length === 0){ showMsg.innerHTML = "Please select at least one file!!"; } else { showMsg.innerHTML = "You selected these files:"; for(let i=0;i<fileBtn.files.length;i++) { showMsg.innerHTML += '<p>' + fileBtn.files[i].name + '<p>'; } } } </script> </body> </html>
Output
This will produce the following output −
Click on “Click me to see all selected file” button to display all the selected files.
- Related Articles
- HTML DOM Input FileUpload disabled 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 accept 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