title: posting image to local server from android client
body: <p><strong>trying to determine</strong>::server is running fine, android is not sending image to server</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>    public void postImageData() throws IOException
      {
          Drawable myDrawable = getResources().getDrawable(R.drawable.image);
          Bitmap bitmap = ((BitmapDrawable)myDrawable).getBitmap();
          HttpClient httpClient = new DefaultHttpClient();
          HttpPost postRequest = new HttpPost("http://127.0.0.1/Details/");
          MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
  
          try{
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              bitmap.compress(CompressFormat.JPEG, 75, bos);
              byte[] data = bos.toByteArray();
              ByteArrayBody bab = new ByteArrayBody(data, "forest.jpg");
              reqEntity.addPart("key", bab);
          }
          catch(Exception e){
              //Log.v("Exception in Image", ""+e);
              reqEntity.addPart("key", new StringBody(""));
          }
          postRequest.setEntity(reqEntity);       
          HttpResponse response = httpClient.execute(postRequest);
          BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
          String sResponse;
          StringBuilder s = new StringBuilder();
          while ((sResponse = reader.readLine()) != null) {
              s = s.append(sResponse);
          }
      }
  </code></pre>
  
  <hr>
  
  <p><strong>Any help to resolve this</strong> ?</p>
  
  <p>Thanks </p>