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...
我正在尝试使用asynctask httpclient在服务器上上传多个图像。我知道如何上传单个图像,但我不知道如何上传多个图像。我试着......
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.
现在我想发送文件路径如何将我的文件路径发送到PHP服务器。
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.
在这段代码中,我使用位图Array photo [photoIndex]来显示多个图像。通过这段代码,我可以将我的多张照片的位图发送到PHP服务器。
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.
这运行正常。
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");
}
#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");
}