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")
multipart/alternative
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