-3

I wanna upload a jpg file from android to server using asp.net web service with ksoap2 library. I searched to net and found noting, Now i just can convert jpg file to binary and send string file and in server convert to jpg file

Somebody please help me.

Phantômaxx
  • 36,442
  • 21
  • 78
  • 108

1 Answers1

1

You can use the Base64 Android class:

String encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);
Bitmap bm = BitmapFactory.decodeFile("/path/to/image.jpg");
ByteArrayOutputStream baos = new ByteArrayOutputStream();  
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object   
byte[] b = baos.toByteArray(); 
morteza jafari
  • 202
  • 1
  • 11