2013-05-16 63 views
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(); 

回答

0

檢查您的清單文件。你有沒有添加Internet權限? 和 在真實設備上測試。

+0

網絡操作也適用於仿真器 –