Learn to splice and upload file data .
{
* Some servers can submit some text content to the server while uploading files.
* Typical applications :
<1> sina Weibo : upload images at the same time , send a Weibo message !
<2> Shopping Review : when you buy a product, post a comment with a picture + comment content !
data format for multiple file uploads 3
{
Content-type:multipart/form-data; Boundary=boundary
//------The following, is the binary data format provided to the server
--boundary\r\n
Content-disposition:form-data; Name= "userfile[]", filename="Aaa.txt"\ r \ n
content-type:application/octet-stream\r\n\r\n
File binary Data
\ r \ n
--boundary\r\n
Content-disposition:form-data; Name= "userfile[]"; filename="AAA copy. txt"\ r \ n
content-type:application/octet-stream\r\n\r\n
File binary Data
\ r \ n
--boundary\r\n
//Username is the name of the script File receive parameter
Content-disposition:form-data; Name="username"\r\n\r\n
Plain Text binary data
\ r \ n
--boundary--
// ------
The above section is the constituent format of the binary data sent to the server ( example )
}
if in iOS , to implement POST upload file , need to follow the above format , splicing data !
because : format is the standard format specified by the company, Apple does not do any encapsulation ! Other languages , have done the encapsulation !
the above three kinds of data splicing format , we need to understand and can be splicing one of their own !
" third-party frameworks do file uploads :
-AFN can upload "a file" at the same time, Some format files , with AFN cannot upload !
-ASI can upload multiple files at the same time, MRC , stopped updating , designed target platform , IOS 2.0/ios 3.0 !
}
Splicing Upload file data