将多个图像路径发送到服务器?

时间:2016-05-13 13:14:29

标签: android asynchronous http-post androidhttpclient

我在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)正在发送其他人不是。{/ p> 是谁能帮我解决这个问题? 提前谢谢......

1 个答案:

答案 0 :(得分:0)

尝试在属性名称中使用索引。

operator int() const