Home / Articles / Programming languages / Markup languages / HTML & CSS / Sending file (file upload) in HTML

Sending file (file upload) in HTML

Sending file (file upload) in HTML
 
Sending file (file upload) in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


The upload field creates an input element to enter file name then the file is sent to the server. The field is created as follows.

<form enctype="multipart/form-data" method="post">
  <input type="file" parameters>
</form>

Form parameters enctype="multipart/form-data" are necessary for the correct file transfer. If it is not specified, only the file path will be passed. Additional parameters are the same as for the text field and shown in table 1.

Table 1. Field parameters for sending file.

Parameter

Description

name

Name of the field. Designed for program that processes form. With specified name it can identify the field.

maxlength

Maximum number of characters allowed in the text.

size

Width of the field.

As the volume of files is usually large, in order for them to be sent to the server, use the POST method, as shown in example 1.

Example 1. Creating field to send a file.

<form action="/cgi-bin/handler.cgi" enctype="multipart/form-data" method="post">
  <b>Please specify the image that will be added:</b><br>
  <input type="file" size="30"><br>
  <input type="submit" value="Send">
</form>

The result is shown below.

Please specify the image that will be added:


 

Read also

Adding a form to a page in HTML

Adding a form to a page in HTML

Text field in HTML

Text field in HTML

Buttons in HTML

Buttons in HTML

Form elements in HTML

Form elements in HTML

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation