How to upload image to server captured from android camera?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10679571/calling-camera-from-an-activity-capturing-an-image-and-uploading-to-a-server">Calling camera from an activity, capturing an image and uploading to a server</a>  </p>
</blockquote>



<p>i want to upload image to server that is captured from camera or image data to server.here is my code.please tell me the parameters to pass in upload activity.I have created main activity for capturing image , created content provider to save data in provider,now i want to upload image to server using my content provider.</p>

<pre><code>main activity

public class MainActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
private final int CAMERA_RESULT = 1;
private final String Tag = getClass().getName();
InputStream is;
 Button button1;
 ImageView imageView1;
 String value;
 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);            

    button1 = (Button)findViewById(R.id.button1);
    imageView1 = (ImageView)findViewById(R.id.imageView1);
    button1.setOnClickListener(this);
   }
   public void onClick(View v) {
   PackageManager pm = getPackageManager();
   if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
   Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
   i.putExtra(MediaStore.EXTRA_OUTPUT, value);
   i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContainerProvider.CONTENT_URI);
  startActivityForResult(i, CAMERA_RESULT);
  } else {
 Toast.makeText(getBaseContext(), "Camera is not available", Toast.LENGTH_LONG).show();
} }

 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 super.onActivityResult(requestCode, resultCode, data);
 Log.i(Tag, "Receive the camera result");
 if (resultCode == RESULT_OK &amp;&amp; requestCode == CAMERA_RESULT) {
 File out = new File(getFilesDir(), "newImage.jpg");
 if(!out.exists()) {
 Toast.makeText(getBaseContext(),
 "Error while capturing image", Toast.LENGTH_LONG)
 .show();
  return;
 }
  Bitmap mBitmap = BitmapFactory.decodeFile(out.getAbsolutePath());
  imageView1.setImageBitmap(mBitmap);
 }
 }

  @Override
  protected void onDestroy() {
   super.onDestroy();
  imageView1 = null;
  }}

  // My provider class

  public class MyFileContainerProvider extends ContentProvider {

 public static final Uri CONTENT_URI = Uri.parse("content://com.example.camerademo/");

 private static final HashMap&lt;String, String&gt; MIME_TYPES = new HashMap&lt;String, String&gt;();

 static {

  MIME_TYPES.put(".jpg", "image/jpeg");

  MIME_TYPES.put(".jpeg", "image/jpeg");

 }

 @Override

 public boolean onCreate() {

  try {

   File mFile = new File(getContext().getFilesDir(), "newImage.jpg");

   if(!mFile.exists()) {

    mFile.createNewFile();

   }

   getContext().getContentResolver().notifyChange(CONTENT_URI, null);

   return (true);

  } catch (Exception e) {

   e.printStackTrace();

   return false;

  }

 }

 @Override

 public String getType(Uri uri) {

  String path = uri.toString();

  for (String extension : MIME_TYPES.keySet()) {

   if (path.endsWith(extension)) {

    return (MIME_TYPES.get(extension));

   }

  }

  return (null);

 }




 @Override

 public ParcelFileDescriptor openFile(Uri uri, String mode)

 throws FileNotFoundException {

  File f = new File(getContext().getFilesDir(), "newImage.jpg");

  if (f.exists()) {

   return (ParcelFileDescriptor.open(f,

     ParcelFileDescriptor.MODE_READ_WRITE));

  }

  throw new FileNotFoundException(uri.getPath());

 }

 @Override

 public Cursor query(Uri url, String[] projection, String selection,

   String[] selectionArgs, String sort) {

  throw new RuntimeException("Operation not supported");

 }

 @Override

 public Uri insert(Uri uri, ContentValues initialValues) {

  throw new RuntimeException("Operation not supported");

 }

 @Override

 public int update(Uri uri, ContentValues values, String where,

   String[] whereArgs) {

  throw new RuntimeException("Operation not supported");

 }

 @Override

 public int delete(Uri uri, String where, String[] whereArgs) {

  throw new RuntimeException("Operation not supported");

 }

} 

   //upload class

public class upload extends Activity {
InputStream is;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);
byte [] ba = bao.toByteArray();
String ba1=Base64.encodeBytes(ba);
ArrayList&lt;NameValuePair&gt; nameValuePairs = new
ArrayList&lt;NameValuePair&gt;();
nameValuePairs.add(new BasicNameValuePair("image",ba1));
try{
HttpClient httpclient = new DefaultHttpClient();
 HttpPost httppost = new
  HttpPost("http://hypermesh-nastran/base.php");
  httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  HttpResponse response = httpclient.execute(httppost);
  HttpEntity entity = response.getEntity();
  is = entity.getContent();
  }catch(Exception e){
  Log.e("log_tag", "Error in http connection "+e.toString());
  }}}
</code></pre>
