How to Upload images to a Webserver?

Put your problem here if it does not fit any of the other categories.

How to Upload images to a Webserver?

Postby burakkilic » Sat Nov 21, 2009 5:14 pm

Hi. I want to upload photos that I have taken with the camera of the Android phone with JSON. What is the best way for this?
Posts: 37
Joined: Thu Oct 01, 2009 10:24 am


Postby padde » Sat Nov 21, 2009 6:00 pm

Even if sending binary data with JSON is a no go.. here are the steps you need to do.

1. read the image data to a byte array (byte[])
2. convert this array to base64 encoded string (you need a lib or class from the internet that does this for you)
3. add the string to a json object
4. send that object to its destination

Due to the base64 encoding the filesize of the image will increase to 133% while transporting.. on the server
side when its decodec back to a byte array its the same as before of course.
Master Developer
Master Developer
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests