Finally found a ready to use
public static void Post () throws Clientprotocolexception, IOException {
Proxy p=new proxy ();
P.sethost ("192.168.1.153");
P.setport ("8888");
HttpClient httpclient = new Defaulthttpclient ();
Httphost proxy = new Httphost (P.gethost (), Integer.valueof (P.getport ()), "http");
Httpclient.getparams (). Setparameter (Connrouteparams.default_proxy, PROXY);
Request Path
HttpPost post = new HttpPost ("xxxxx");
Add Header header Information
Post.setheader ("User-agent", "mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.1;) ";
Note Here must not add the Content-type:multipart/form-data property because there is a boundary parameter property is not controllable. This value is generated by the browser. If the force indicates and May
Causes the boundary value inconsistency to request the failure detail see http://blog.csdn.net/xiaojianpitt/article/details/6856536
Post.setheader ("Content-type", "Multipart/form-data");
Post.setheader ("Host", "* * *");
Post.setheader ("accept-encoding", "gzip");
Post.setheader ("CharSet", "Utf-8");
Filebody filebody = new Filebody (New File ("xxxx"), "Image/pjpeg", "utf-8");
multipartentity entity = new multipartentity ();
Add Message body Information
Entity.addpart ("xxxx", New stringbody ("xxx", Charset.forname ("Utf-8"));
Entity.addpart ("ImageFile", filebody);
Post.setentity (entity);
HttpResponse response = Httpclient.execute (POST);
if (Httpstatus.sc_ok==response.getstatusline (). Getstatuscode ()) {
Httpentity Entitys = response.getentity ();
if (entity!= null) {
System.out.println (entityutils.tostring (Entitys));
}
}
Httpclient.getconnectionmanager (). Shutdown ();
}