Need to push a picture from the camera in a POST request to send to the server? How can I do that?

  • @kaaa, Try to write more detailed questions. Explain what you see the problem, how to reproduce it, etc. - lsillarionov
  • 2
    Here is your recipe for happiness: 1. Google - Android take picture from camera 2. Google - Android post request send image Done! - Vladyslav Matviienko
  • I get a picture from the camera of the device, save it (for example) and want to send it to the server using a post request. I would like to see a piece of code (JAVA) that will allow me to do this. If there are other options, not through the post, I am ready to consider them. - kaaa
  • one
    To see a piece of code, go to Google and type Android post request send image. Click on the first link in the output, and, oh, a miracle, there will be a piece of code! - Vladyslav Matviienko
  • Thank you for your reply. It seems found on this request. I will understand and try. - kaaa

1 answer 1

I did it like this and it turned out to send a picture to the server in a post request.

public void UplPhoto(String strURL){ SyncHttpClient client = new SyncHttpClient(); RequestParams params = new RequestParams(); params.put("text", "some string"); try { params.put("image", new File("/mnt/sdcard/DCIM/Camera/1.jpg")); } catch (FileNotFoundException e) {e.printStackTrace(); } client.post(MAIN_URL + "/mapi/photo.php", params, new TextHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { } @Override public void onSuccess(int statusCode, Header[] headers, String responseString) { } }); }