(from:http://home.meegoq.com/home-space-do-blog-uid-17-id-81.html)
HTTP Multipart/form-data Upload Method description
has been read 123 times 2010-12-1 11:13 | Personal Category: WEB Learning | Keywords: HTTP multipart
The HTTP upload file feature uses the Protocol rfc1867 (Http://www.ietf.org/rfc/rfc1867.txt) for the HTTP protocol. Client-side browsers, such as Microsoft IE, Mozila, Opera, etc., follow this specification to send user-specified files to the server. Server-side web-based programs, such as PHP, ASP, JSP, etc., can be in accordance with this specification, the user sent to resolve the file. Microsoft IE, Mozila, Opera has supported this protocol by using a special form on the Web page to send files. Most HTTP servers, including Tomcat, already support this protocol and can accept files sent. A variety of Web-page programs, such as PHP, ASP, JSP, for uploading files have done a good package.
The request header is as follows, if there is no character after each line, it indicates that there are no characters after it, directly attached to the next line of characters:
Post/handset/save http/1.1
\ r \ n
Host:gateway.ereneben.com
\ r \ n
Accept: */*
\ r \ n
User-agent:t1 HTTP Adaptor
\ r \ n
Connection:keep-alive
\ r \ n
User-serial:1234567890abcdefghijklmc
\ r \ n
user-cert:q+xug7315jeizrw9ativjhcv0d8+4cn5zglzwbps+ 1fjucl5bijd859rg4bubijrjok2dbeummc8xmfacuxj2ssyxmty63iu0tnhscjhgpmo4bfv0px+v9cwklixna/+ 7bx2t3scz7tmpfrylkecf3xm4rb9q9/6htfkxcv99q4=
\ r \ n
user-id:122
\ r \ n
Content-type:multipart/form-data; boundary=--------------------------7d93b91e2404d①
\ r \ n
Content-length:299⑦
\ r \ n
\ r \ n
-----------------------------7d93b91e2404d②
\ r \ n
Content-disposition:form-data; Name= "Update1"; Filename= "/storage card/eben.txt"
\ r \ n
Content-type:application/octet-stream; Charset=gbk
\ r \ n
Content-transfer-encoding:binary
\ r \ n
\r\n③
Ckatom C + + Class Reference (Visual C + +)
\r\n④
-----------------------------7d93b91e2404d--⑤
\r\n⑥
Description
①content-type must specify boundary. The previous "---------------------------7d" is a unique symbol of IE. The subsequent string "7d93b91e2404d" is a randomly generated string. Boundary is the file split line in the form when the file is uploaded.
② the dividing line in the style of the request report
"-----------------------------7d93b91e2404d"
than boundary=---------------------------7d93b91e2404d
The split line in front of "--".
The ③ between the request header and the file data of the uploaded file in the form is "\ r \ n \ r \ Nand". The same as the delimiter between the HTTP request header and the report style.
④ "\ r \ n" is required to append the end of the upload file.
⑤ the split line "-----------------------------7d93b91e2404da--" at the end of the last file, which means "--" is required before and at the end of the boundary. The last split line is special, be careful not to forget the "--" behind.
⑥ the end of the last request message needs to append the delimiter "\ r \ n".
⑦ the last thing to note is that the value of the Content-length parameter in the request header is the length of the entire newspaper style. That is, the entire length from the first character of the split line ② to the end of the message "\ r \ n". Be careful not to omit the length of the "\ r \ n" At the end of the calculation message, otherwise the value of the Content-length parameter becomes 297 and an error occurs.
The above precautions must be followed, otherwise the request will go wrong.
Http://www.chongchonggou.com/g_92052682.html
HTTP Multipart/form-data Upload Method description (with 8 points of note)