I relatively recently began to study programming for android .. So I had a question: how do I download images to a site in android applications .. such as in VC, OK, etc. applications when loading profile pictures for example. Ideally, you need a piece of code for an example .. Either at least give some links, or at least in which direction to tell me.

1 answer 1

Here is a similar question and working answer: How to send a picture from a camera to a POST request? Post request we send an image to your site, in photo.php we accept it

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) { } }); } 

Post request we send an image to your site, in photo.php we accept it