跳到主文
部落格全站分類: 數位生活
public static void Update() throws Exception { HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter( CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpPost httppost = new HttpPost("http://mpss.csce.uark.edu/~tsumar/test/upload_file.php"); File file = new File("image.jpg"); MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, "image/jpeg"); mpEntity.addPart("file", cbFile); httppost.setEntity(mpEntity); System.out.println("executing request " + httppost.getRequestLine()); HttpResponse response = httpclient.execute(httppost); HttpEntity resEntity = response.getEntity(); System.out.println(response.getStatusLine()); if (resEntity != null) { System.out.println(EntityUtils.toString(resEntity)); } if (resEntity != null) { resEntity.consumeContent(); } httpclient.getConnectionManager().shutdown();}
資訊鏟
techdrew 發表在 痞客邦 留言(0) 人氣( 71 )
本部落格內容僅限年滿十八歲者瀏覽。 若您未滿十八歲,請立即離開。
已滿十八歲者,亦請勿將內容提供給未成年人士。
請先 登入 以發表留言。