2013-05-16 222 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

网络操作也适用于仿真器 –