How do we upload external file on a website using HTML forms?


If you want to allow a user to upload an external file to your website, you need to use a file upload box, also known as a file select box. This is also created using the <input> element but type attribute is set to file.

Example

Live Demo

You can try to run the following code to upload an external file to your website −

<!DOCTYPE html>
<html>
   <head>
      <title>File Upload</title>
   </head>
   <body>
      <form>
         <input type = "file" name = "upload" accept = "image/*" />
      </form>
   </body>
</html>

Here are the attributes of the file upload box −

Sr.No
Attribute & Description
1
name
Used to give a name to the control which is sent to the server to be recognized and get the value
2
accept
Specifies the types of files that the server accepts.

Updated on: 17-Jun-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements