Android Sending Data to PHP Server

I am creating a sign up form where i need to send the following data to the PHP server to create the user account

  1. First Name
  2. Last Name
  3. Email
  4. PAssword
  5. Image

i am sending the first four via JSON. now i am wondering how to include the image and send it to the server.


you can transfer byteStream of image by HttpConnection .

i followed this link for the same .

for this use the multipartentity concept. for reference see the below code

MultipartEntity req=new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bm.compress(CompressFormat.JPEG, 75, bos);
        byte[] data = bos.toByteArray();
        ByteArrayBody bab = new ByteArrayBody(data, "icon.png");
        req.addPart("image", bab);

in that req.addPart("image", bab); "image" is the xml code.u sholud collect it .

you should go for Base64 encoding to send Image to sever.

see this link..Binary Data in JSON String. Something better than Base64

First you need to decide what kind of image you want to send. Do you want to choose an image from sd-card or take a photo with camera?

Here is very good tutorial how to do it, which even includes explanation how to implement croping of the image.

Next step, you will need to upload this file. You can get good information about that from here.

Need Your Help

Change the div to be scrolled to after click?

jquery scrollto

I have a set of three pages where I am using ScrollTo to navigate. The issue I am having is that I need page 2 to be a static page but page 1 and page 3 to run an ajax call when they are scrolled t...

Check if page works using SSL in PHP

php http ssl

I need to check if a page works using SSL connection. I know how to check $_SERVER['HTTPS'] == 'on'. Is this a good way of doing it, or should I use other logic?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.