1

I need to send the selected image to a web server. The code for selecting the image from the sdcard is shown below. I have searched many times in google. But still not finding a proper solution to my problem. Can anyone please suggest me how to send the selected image to a web server. The web server is a ASP.net web server. I have found many code to send data to php web server on the internet, but didn't find a code to send to an ASP.net web server. Please help me out. I'm new to android. So I didn't know the steps of sending image/ video data through a web server.

// I have added a button to select the image

Button imgbrowse=(Button)findViewById(R.id.imgbrowse); 

imgbrowse.setOnClickListener(new OnClickListener() 
{

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, RESULT_LOAD_IMAGE);

        }
});

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };

        Cursor cursor = getContentResolver().query(selectedImage,
                filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);

//the path where the image is located is stored in string variable

String picturePath = cursor.getString(columnIndex);         
        cursor.close();

    //Displaying the selected image in the image view. 

        ImageView imageView = (ImageView) findViewById(R.id.imageView1);
        imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

    //Displaying the path of the selected image

        TextView tv=(TextView)findViewById(R.id.textView5);
        tv.setText(picturePath);

    }
}
njnjnj
  • 978
  • 4
  • 23
  • 58
  • You might also want to have a look at this : http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content – 2Dee Feb 05 '14 at 19:42

0 Answers0