title: Uploading a bitmap to the server with http protocol
body: <p>i have a camera Activity after which i take a picture  and saving it to gallery and uploading to the server My upload  code  is not working, i need  help on this?</p>
  
  <p>// image capture</p>
  
  <pre><code>Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
  startActivityForResult(intent, 0);
  </code></pre>
  
  <p>//image Saving</p>
  
  <pre><code>if(requestCode==0&amp;&amp;resultCode==RESULT_OK)
  
  {
  
      Bundle extras = data.getExtras();
      Bitmap b = (Bitmap) extras.get("data");
  
      ImageView mImg;
      mImg = (ImageView) findViewById(R.id.head);
      mImg.setImageBitmap(b);
  
      // save image to gallery
      Shot = "HeadShot"; //Long.toString(System.currentTimeMillis());
      MediaStore.Images.Media.insertImage(getContentResolver(), b, Shot, NAME);
  
  }
  </code></pre>
  
  <p>//Upload to  the server</p>
  
  <pre><code>public void Upload(String url, HttpEntity imgdata) throws Exception, Exception {
  
      DefaultHttpClient client = new DefaultHttpClient();
      HttpPost post = new HttpPost(url);
      post.setHeader("Content-Type", "bitmap; charset=utf-8");
      post.setURI(new URI(url));
      post.setEntity(imgdata);
      HttpUriRequest request = post;
      HttpResponse response = client.execute(request);
      HttpEntity entity = response.getEntity();
      return entity.getContent();
  }
  </code></pre>