
- 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
How to set a value to a file input in HTML?
To set a value to a file input in HTML, use the type attribute. It defines a Browse button to upload the files with a file-select field −
<input type = "file">
However, we cannot set a specific value to a file input in HTML for security reasons. Nothing will happen, even if, let’s say we set a value like this −
<input type="file" value="E:/new/resume.docx">
Let us see some examples to upload single and multiple files with input type file.
File select with only one file
Example
This allows a user to upload only a single file −
<!DOCTYPE html> <html> <body> <h1>Resume</h1> <p>Upload your resume:</p> <form action="/details.php"> <label for="myfile">Select a file:</label> <input type="file" id="myfile" name="myfile"><br><br> <input type="submit"> </form> </body> </html>
Output
Click the Choose File button to upload the file −

We will upload the Resume.docx file above.
File select with multiple files
Example
This allows a user to upload multiple files. Set multiple in the input type and the button will display Choose Files for multiple files −
<!DOCTYPE html> <html> <body> <h1>Resume</h1> <p>Upload your resume:</p> <form action="/details.php"> <label for="myfile">Select a file:</label> <input type="file" id="myfile" name="myfile" multiple><br><br> <input type="submit"> </form> </body> </html>
Output

We clicked on Submit and selected 3 files as shown below −
Click Open and now the count 3 is near the Choose Files button i.e. we uploaded 3 files successfully −

- Related Articles
- How to get a key/value data set from a HTML form?
- How to set “value” to input web element using selenium?
- Using Selenium Web Driver to retrieve value of a HTML input.
- How to set the URL of the media file in HTML?
- How to give a limit to the input field in HTML?
- How to add a file uploads function to a webpage in HTML?
- How to Insert a value to a hidden input in Laravel Blade?
- How to include another HTML file in an HTML file?
- AngularJS and HTML5 date input value - how to get Firefox to show a readable date value in a date input?
- HTML input value Attribute
- How to specify a minimum value in HTML?
- How to add a set of frames in HTML?
- How to create a file upload button with HTML?
- How to use a textarea (a multi-line text input field) in HTML?
- How to add a regular expression that an input element's value is checked against in HTML?
