Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <input> type="file"

The <input> tag with a type="file" attribute creates a file selection control.

Clicking it will open file-selection dialog.

Example

#

An <input> element of type file.
Select one or more image files and then click Upload to upload the file(s).

Select and Upload images

The selected filename(s) will display next to the input control.

<form action="/tutorial/fileupload.html" enctype="multipart/form-data">
 <fieldset>
   <legend>Select and Upload images</legend>

   <input type="file" name="file"
          accept="image/*" multiple><br /><br />

   <input type="submit" value="Upload">
  </fieldset>
</form>

Using input type="file"

The <input type="file"> specifies a file selection control.

This element is rendered with a button and label, although in each browser it looks different.

The button opens a file selection dialog, and the label will display the selected filename(s).

Adding the multiple attribute will allow selecting multiple files in the dialog.


Syntax

<input type="file">

Browser support

Here is when type="file" support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <input>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides