Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use this code to upload images It's working fine for me </p> <pre><code>public class UploadToServer extends AsyncTask&lt;String, String, String&gt;{ @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... args){ String status=""; String URL = ""; try{ Log.d("Image Path ======",TakePicture.file.toString()); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(URL); File file = new File(TakePicture.file.toString()); FileBody bin = new FileBody(file); MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("Content-Disposition", new StringBody("form-data")); reqEntity.addPart("name", new StringBody("Test")); reqEntity.addPart("filename", bin); reqEntity.addPart("Content-Type", new StringBody("image/jpg")); httppost.setEntity(reqEntity); Log.d("Executing Request ", httppost.getRequestLine().toString()); HttpResponse response = httpclient.execute(httppost); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { Log.d("Response content length: ",resEntity.getContentLength()+""); if(resEntity.getContentLength()&gt;0) { status= EntityUtils.toString(resEntity); } else { status= "No Response from Server"; Log.d("Status-----&gt;",status); } } else { status = "No Response from Server"; Log.d("Status-----&gt;",status); } } catch (Exception e) { e.printStackTrace(); status = "Unable to connect with server"; } return status; } @Override protected void onPostExecute(String status) { super.onPostExecute(status); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload