4

I am trying to upload multiple image in server with using a asynctask httpclient. i know to how to upload single image but i cant know how to upload multiple image. i try like...

for (int i = 0; i < photo.length; i++) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    photo[photoIndex].compress(Bitmap.CompressFormat.PNG, 100, stream);
    InputStream in = new ByteArrayInputStream(stream.toByteArray());
    params.put("uploaded_file[" + photo[i] + "]", in,
    System.currentTimeMillis() + ".jpg");
}

Now I want to send file path how to send my file path in to PHP server.

In this code I am using bitmap Array photo[photoIndex] for multiple images. by this code I can capable to send bitmap of my multiple photo to the PHP server.

And this is code for upload single photo.

ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo[photoIndex].compress(Bitmap.CompressFormat.PNG, 100, stream);
InputStream in = new ByteArrayInputStream(stream.toByteArray());
params.put("uploaded_file", in,
System.currentTimeMillis() + ".jpg");

This is running properly.

4
  • Are you getting any Error to Upload multiple Images ? Commented May 9, 2015 at 5:06
  • no buddy ... but i can able to send multi bitmap on to server but i want o path of that file i dont know how to do that tell me that how can do that?? Commented May 9, 2015 at 5:19
  • Instead of adding multiple image, why don't you create a zip file including images and then upload that zip and unzip that on server (by using php) Commented May 9, 2015 at 5:31
  • no bro i have to send file path coz i m working on live service Commented May 9, 2015 at 7:13

1 Answer 1

1
for (String p : YOURARRAYLIST) {
       ByteArrayOutputStream stream = new ByteArrayOutputStream();
       photo[photoIndex].compress(Bitmap.CompressFormat.PNG, 100, stream);
       InputStream in = new ByteArrayInputStream(stream.toByteArray());
       params.put("uploaded_file", in,
       System.currentTimeMillis() + ".jpg");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.