In my android application, I am able to capture an image and store in SD card. I have a select button and check boxes to select pictures. But I don’t know how to upload the selected images to a php server to display via my website. Code is posted below, Please help by telling how to upload those selected images. Thank you
imageAdapter = new ImageAdapter();
imageAdapter.initialize();
imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
imagegrid.setAdapter(imageAdapter);
final Button selectBtn = (Button) findViewById(R.id.selectBtn);
selectBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final int len = imageAdapter.images.size();
int cnt = 0;
String selectImages = "";
for (int i = 0; i < len; i++) {
if (imageAdapter.images.get(i).selection) {
cnt++;
selectImages = selectImages
+ imageAdapter.images.get(i).id + ",";
}
}
if (cnt == 0) {
Toast.makeText(getApplicationContext(),
"Please select at least one image",
Toast.LENGTH_LONG).show();
} else {
selectImages = selectImages.substring(0,selectImages.lastIndexOf(","));
Intent intent = new Intent(MainActivity.this,
UploadQueue.class);
intent.putExtra("Ids", selectImages);
startActivityForResult(intent, UPLOAD_IMAGES);
}
1) Create a webservice on your server
2) convert your image to Base64 string in android
3) send that string to the webservice by ksoap2
4) convert back the string to image in webservice (You do not need to convert it to Image File if not needed)
5) save it on hard disk of the server
Edit:
or