tags:

views:

89

answers:

1

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?

// image capture

        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            startActivityForResult(intent, 0);

//image Saving

  if (requestCode == 0 && 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);

    }

//Upload to the server

                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();
        }
+1  A: 

Here's a nice upload code sample. It uploads a file - exactly what you need http://stackoverflow.com/questions/3038409/how-to-send-http-post-request-and-recieve-response/3038747#3038747.

Fedor
i used that code, but no use
Srikanth Naidu
So what exactly the problem is...
Fedor