0
在我的應用我想多張圖片上傳到服務器,包括音頻和圖像.. 我使用MultipartEntity,但是當我打電話POST方法我越來越HttpHostConnectionException: connection refused
連接拒絕的Android PHP服務器
這裏我的代碼:
MultipartEntity entity=new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
String path="mnt/sdcard/TAUKY/PICTURE/IMAGE_20130507_170848.png";
File f = new File(path);
String audio_path="mnt/sdcard/TAUKY/SOUND/SOUND_20130513_185502.wav";
File f_auido=new File(audio_path);
entity.addPart("image", new FileBody(f));
entity.addPart("audio", new FileBody(f_auido));
entity.addPart("taukyname", new StringBody("My tauky"));
entity.addPart("userId", new StringBody("63"));
hpost.setEntity(entity);
HttpResponse response = htpclnt.execute(hpost);
HttpEntity resEntity = response.getEntity();
Toast.makeText(getApplicationContext(), "Sucess"+response, 1000).show();
網絡操作也適用於仿真器 –