Function of the enctype attribute of form labels, formenctype

Source: Internet
Author: User

Function of the enctype attribute of form labels, formenctype

Enctype is the encoding type used by the browser when data is sent back to the server. The encoding types include:


1. application/x-www-form-urlencoded
This is the default encoding type when data is sent through a form. When the enctype attribute is not set in the from label, the default value is application/x-www-form-urlencoded. The application/x-www-form-urlencoded encoding type encodes the data sent in the form into name/value pairs. This is the standard encoding format. When the form ACTION is POST, the browser encapsulates form data into the http body and sends it to the server. When the form ACTION is GET, the application/x-www-form-urlencoded encoding type converts the data sent in the form into a string (name = coderbolg & key = php ), then append the string to the end of the URL and use? Split, and then request the new URL. When sending an AJAX request to the server in POST mode, we 'd better specify the request header as the application/x-www-form-urlencoded encoding type. The method is added after the xmlobject. open () method
xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
Otherwise, the server will not receive POST data.


Ii. multipart/form-data
This is specially used to transmit special types of data, such as non-text content uploaded by us, such as slice or MP3. This encoding type is not character encoding. Data is transmitted to the server in binary format. In this case, if the request cannot directly obtain the value of the corresponding form, the stream object should be used, decodes binary data uploaded to the server to read the data.


Iii. text/plain
The data is encoded in plain text, without any controls or format characters.
What does enctype = "multipart/form-data" in form mean?

In the form, enctype = "multipart/form-data" indicates the MIME encoding of the form. By default, the encoding format is application/x-www-form-urlencoded and cannot be used for file upload. Only multipart/form-data can be used to completely transmit file data, perform the following operations.

Enctype, which is in the form?

In the form, enctype = "multipart/form-data" indicates the MIME encoding of the form. By default, the encoding format is application/x-www-form-urlencoded and cannot be used for file upload. Only multipart/form-data can be used to completely transmit file data, perform the following operations.
Reference: zhidao.baidu.com/question/5712038.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.