File Upload/Select box in HTML

The File upload box allow a user to browse for a local file and send it as an attachment to the form data. It normally rendered as a text box with a button that enables the user to browse for a file. It is also known as a file select box. This is also created using the <input> element but type attribute is set to file. Example :
<!DOCTYPE html>
<html>
   <head>
   <title>File Upload/Select box</title>
   </head>
   <body>
     <form action="login_page.php" method="post">
        Select An Image File To upload :
        <input type="file" name="upload" accept = "image/*" />
     </form>
   </body>
</html>
The output of above code will be :


Attributes :

The attributes used in the File Upload Box are as follows :

  • name : Used to give a name to the control which is sent to the server to be recognized and get the value.
  • accept : Specifies the types of files that the server accepts.