On the difference and usage of application/x-www-form-urlencoded and multipart/form-data in Content-type

Source: Internet
Author: User

The Enctype property of the form represents how the page form data is encoded when it is transmitted to the server, and is commonly used in two ways: application/x-www-form-urlencoded and Multipart/form-data, which are application/by default. X-www-form-urlencoded.
1, application/x-www-form-urlencoded:
The form data is encoded as a name/value pair, which is the standard and default encoding format. When the action is get, the client converts the form data into a string append to the URL and splits it. When the action is post, the browser encapsulates the form data into the HTTP body and then sends it to the server.
Data construction When application/x-www-form-urlencoded is passed:
Username=twm&[email protected]

2, Multipart/form-data:
Multipart means that a single message header contains solutions for multiple message bodies. Multipart media types are useful for sending non-text media types. Often used for file uploads.

Multipart/form-data is just a kind of multipart. The following types are commonly used (note: Any multipart subtypes that are not recognized at execution time are considered sub-type "mixed")

HTML FORM data (see Ch. 9 and App. B) multipart/form-data
Messages With multiple parts multipart/mixed
Messages with multiple, alternative parts
Message with multiple, related parts multipart/related
Multiple parts is digests multipart/digest
for reporting of email stat US (admin.) Multipart/report
Order of parts does not matter multipart/parallel
Macintosh file data multipart/appledouble
Aggregate messages; descriptor as header multipart/header-set
Container for voice-mail multipart/voice-message
Infinite multiparts-see Chapter 9 (Netscape) multipart/x-mixed-replace

When the client initiates the request:
The request header contains content-type: "Multipart/form-data; boundary=---------------------------30613490016641 ", indicating that the enctype of the form is multipart/form-data, separating the delimiters for each control field ( Boundary) is '---------------------------30613490016641 '.
Each field of the requested content is divided into a small part, and contains a value that is the head of the "content-disposition" of "Form-data"; a "name" property corresponds to the ID of the field.

Multipart/form-data data construction When passing, see figure:

On the difference and usage of application/x-www-form-urlencoded and multipart/form-data in Content-type

Related Article

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.