HTML <input type=”file”>

The HTML <input type=”file”> element is used to create a file input box in forms. It allows users to browse and select files to upload from the devices. When the form is submitted, the selected file(s) can be uploaded to the server.

Syntax

<input type="file"> 

Example: In this example, we will demonstrate the use of the HTML <input type=”file”> element.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML Input Type File
    </title>
</head>

<body style="text-align: center;">
    <h2>HTML &lt;input type = "file"&gt;</h2>

    <form action="#">
        <label for="image_file">Select Image</label>
        <input type="file" id="image_file">
    </form>
</body>

</html>

Output

Supported Browsers

The browsers supported by <input type=”file”> are listed below:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 11
  • Safari 1

Contact Us