The format of the post form must not change, especially the format of the data section in the form. Last night's bug is because in the form of the data part of the increase in content-length, the superfluous, resulting in the server received the data in the body of the number of characters (more out of the character is Content-length). Content-length should be assigned in the HTTP header. Hereby record.
In addition, the post form is not compressed or the server is not recognized.
Finally, enclose the form in the correct format:
HTTP HEADER:
Content-type:multipart/form-data; boundary=------uploadboundary------
HTTP Body:
--------uploadboundary------
Content-disposition:form-data; Name= "Shopid"
50000
--------uploadboundary------
Content-disposition:form-data; Name= "Name"
Photo Name (Utf-8)
--------uploadboundary------
Content-disposition:form-data; Name= "token"
309afac7f5734be7fea7c660b54f2f42dfa9ae83ed6f9c6e789dad6d4449d397b6b7c434497b2801ac5e5ba0a25aeb6d242910b4d98b40f497f252efe 239603c986fda9083c1eab7b8802dd4ee0c309baaac8b7dbdcc8f24769e661858184267
--------uploadboundary------
Content-disposition:form-data; Name= "Photo"; Filename= "Whatever.jpg"
Content-type:image/jpg
Content-transfer-encoding:binary
JPG data
--------Uploadboundary--------
SAMPLE CODE (JAVA):
String CRLF = "/r/n";
String boundary = "--------uploadboundary------";
Bytearraybuffer buffer = new Bytearraybuffer (data.length + 1000);
Post.setheader ("Content-type", "multipart/form-data; boundary=------uploadboundary------");
Shopid
Buffer.append (boundary);
Buffer.append (CRLF);
Buffer.append ("Content-disposition:form-data; name=/"Shopid/");
Buffer.append (CRLF);
Buffer.append (SHOPID);
Name
Buffer.append (boundary);
Buffer.append (CRLF);
Buffer.append ("Content-disposition:form-data; name=/"name/");
Buffer.append (CRLF);
Buffer.append (Name.tochararray ("Utf-8"));
Token
Buffer.append (boundary);
Buffer.append (CRLF);
Buffer.append ("Content-disposition:form-data; name=/"token/");
Buffer.append (CRLF);
Buffer.append (token);
Data
Buffer.append (boundary);
Buffer.append (CRLF);
Buffer.append ("Content-disposition:form-data; name=/"photo/"; filename=/"whatever.jpg/");
Buffer.append (CRLF);
Buffer.append ("content-type:image/jpg");
Buffer.append (CRLF);
Buffer.append ("Content-transfer-encoding:binary");
Buffer.append (CRLF);
Buffer.append (CRLF);
Buffer.append (data);
Buffer.append (CRLF);
Buffer.append (boundary);
Buffer.append ("--");
Buffer.append (CRLF);
bytearrayentity entity = new Bytearrayentity (Buffer.tobytearray ());
Post.setentity (entity);
return entity;