【发布时间】:2016-05-13 13:14:28
【问题描述】:
我在doInBackground写了下面的代码,
InputStream in = null;
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
System.out.println("calling API here");
HttpPost httppost = new HttpPost("my url");
MultipartEntity reqEntity = new MultipartEntity();
if (imageList != null) {
for(int i=0;i<imageList.size();i++) {
File f= new File(imageList.get(i));
in = new BufferedInputStream(new FileInputStream(f));
reqEntity.addPart("file[]",f.getName(), in);
}
}
reqEntity.addPart("mobile",owner_mobile);
reqEntity.addPart("reg_code",reg_code);
reqEntity.addPart("book_id",book_id);
reqEntity.addPart("adv_amount",advAmountValue);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
问题是当我将multiple image(s) 发送到server 时,只有第一张图片(for e.g, 23457352.jpg) 正在发送其他人不是。
谁能帮我解决这个问题? 提前谢谢...
【问题讨论】:
-
那是你的完整代码吗?您有未关闭的
try和if语句。
标签: android asynchronous http-post androidhttpclient