On the difference between application/x-www-form-urlencoded and Multipart/form-data

Source: Internet
Author: User

Reproduced from: http://www.jb51.net/article/51377.htm

In the syntax of a FORM element, enctype indicates the format of the submitted data

Use the Enctype property to specify the type of encoding used by the browser when the data is sent back to the server.

Below is the description:

application/x-www-form-urlencoded: Form data is encoded as a name/value pair. This is the standard encoding format.

Multipart/form-data: Form data is encoded as a message, and each control on the page corresponds to one part of the message.

Text/plain: Form data is encoded in plain text without any controls or formatting characters.

Add

The Enctype property of the form is encoded and is commonly used in two ways: application/x-www-form-urlencoded and Multipart/form-data, and the default is application/ X-www-form-urlencoded.

When the action is get, the browser converts the form data into a string (Name1=value1&name2=value2 ...) using x-www-form-urlencoded encoding. , and then append the string to the URL and use the? Split to load the new URL.

When the action is post, the browser encapsulates the form data into the HTTP body and sends it to the server.

If you don't have a type=file control, you can use the default application/x-www-form-urlencoded.

But if you have type=file, you will need to use Multipart/form-data. The browser splits the entire form into controls and adds Content-disposition (form-data or file), Content-type (default Text/plain), name (control name) to each section, and add a separator (boundary).

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.