Android upload image to server

Android upload image to server

Hey guyz in this post we will learn how to make a android upload image to server. We will be sending image as a string from the android app and that string will be decoded in our php script and uploaded to the server, We will be using Base64 encryption.
In this post we will doing network request in android if your are not familiar with network request, Check out this post
JSON parsing in android using PHP and MySqli
Android JSON parser and populating in a listview

Demo of Android upload image to server


This php file will handle the request send by our android app, decode the image and store it in the pic directory.


Project structure

In this project we have 2 java file &

  1. In this file we will have all the code to select a image,Encode a image, etc etc
  2. by this file we will send the encoded image & image name to saveImage.php file on the server and return the response to

Android upload image to server



8 thoughts on “Android upload image to server”

  1. Hey, i tried using your code to try uploading an image file into the server remotely. The file seem to be uploaded onto the server, however the file seems to be corrupted. (0 bytes jpeg file named as ‘0.jpg’). Could it you please advice?

  2. If i use Django in place of php..will this code give correct result??
    i am having Django code that works correct when i run it with cmd.i want to run it with android app,as you did.

  3. everything work fine, image file is uploaded but
    1) named as [.jpg] – no name
    2) filesize is 0byte

    i didnt change any of your code (all copy & paste)
    may i know what went wrong? thanks

Leave a Reply

Your email address will not be published. Required fields are marked *