Article 4: multipart/form-data details

Source: Internet
Author: User

Reprinted please indicate the source http://blog.csdn.net/yankai0219/article/details/8159701
Main Content 1. What is multipart/form-data? 2. Upload steps: 3. multipart/form-Data Format 1) Overview 2) Details


1. What is multipart/form-data?Multipart/form-data is a method for uploading files. Multipart/form-data is actually the way the browser uploads files using forms. The most common situation is: when writing an email, add attachments to the email. attachments are usually added using forms, that is, uploaded to the server in the multipart/form-data format.
2. Upload steps:First, the client and the server establish a connection (TCP protocol ).
Second, the client can send data to the server. Because the Upload File actually sends a request to the server.
Third, the client sends data to the server in the format of multipart/form-data. (This is important ).
3. multipart/form-Data Format1) OverviewIn fact, there are multiple Representation Methods for multipart/form-data formats, but I think the most authoritative one is as follows:

First, there are some basics you need to understand about multipart/formdata posts. each part consists of at least a name and a contents part. if the part is made for file upload, there are also a stored Content-Type
And a filename. below, we'll discuss what options you use to set these properties in the parts you want to add to your post. first, you need to understand some basic knowledge about multipart/formdata post. Each part contains at least one name and one content part. If this part is used to upload files, you can also have Content-Type and filename information. (From http://curl.haxx.se/libcurl/c/curl_formadd.html)
I like to capture packets through Wireshark and fully understand its content. Packet Capture Website: Fast-loading network disk. Packet capture content: the POST request when the file is uploaded. The field indicating multipart/form-data in the captured packet: MIME multipart media encapsulation.
2) Details:First, we will introduce the correspondence between fields in Wireshark and multipart/form-data: MIME multipart media encapsulation: represents the data in the entire multipart/form-data upload file. Encapsulated multipart part: represents the data of different parts of the form. Boundary: used to separate data from different parts of a form. Secondly, details: 1) Mime multipart media encapsulation, type: multipart/form-data, boundary: "---------- ei4ij5i5ef1gl6km7ef1ch2ae0ei4"This line indicates that the request is in the multipart/form-data format, and boundary is the string "---------- ei4ij5i5ef1gl6km7ef1ch2ae0ei4. 2) Boundary: boundary: used to separate data of different parts of a form. In fact, each part of the data starts with "--" + boundary (this is the standard content described in the MIME standard ). 3) encapsulated multipart part: the description of this part of data that follows boundary: Content-dispostion: Form-data; name = "FILENAME" \ r \ nEach part must have at least one name and one content part.

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.