Sending a file
The field for sending the file creates the form element as a text field for entering the file name, which is sent to the server. The field is created as follows.
<Input type = "file" options>
</ Form>
The form parameters enctype = "multipart / form-data" are needed to correctly transfer the file. If you do not specify it, only the path to the file will be transferred. The additional parameters are the same as for the text field and are shown in Table. 1.
Parameter | Description |
---|---|
Name | The name of the field. It is intended for the form handler to be able to identify this field. |
Maxlength | The maximum number of characters allowed in the text. |
Size | The width of the field. |
Because the file size is usually large enough, you must use the POST method to send them to the server, as shown in Example 1.
Example 1. Creating a field to send a file

<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text / html; charset = windows-1251">
<Title> Sending a file </ title>
</ Head>
<Body>
<Form action = "/ cgi-bin / handler.cgi" enctype = "multipart / form-data" method = "post">
<P> <b> Please specify the picture you want to add: </ b> </ p>
<P> <input type = "file" size = "30"> </ p>
<P> <input type = "submit" value = "Send"> </ p>
</ Form>
</ Html>
As a result, we get the following (Fig. 1).
Fig. 1. Field type for sending a file
Copyright © www.htmlbook.ru
Comments
When commenting on, remember that the content and tone of your message can hurt the feelings of real people, show respect and tolerance to your interlocutors even if you do not share their opinion, your behavior in the conditions of freedom of expression and anonymity provided by the Internet, changes Not only virtual, but also the real world. All comments are hidden from the index, spam is controlled.