Reputation: 421
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.
Upvotes: 4
Views: 1532
Reputation: 802
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");
}
Upvotes: 1