Sending file (file upload) in HTML

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.