Android Upload Image to Server Using Volley

Here you will learn about android upload image to server using volley library.

At server side I have used java web service and for sending image to server volley library is used.

How it works?

  • The user chooses an image from gallery and click on upload button.
  • The image is then converted into Base64 string format and sent to server using volley network library.
  • Now at server side this Bas64 string is converted back into image and stored at some location.


Android Upload Image to Server Using Volley

Server Code

Below is the code for server. It is a java web service. If you don’t know how to make web service in java then read below tutorial.

Also Read: Create Simple Java RESTful Web Services Using Jersey


Android Project

1. Now create a new android project with package name com.androiduploadimage


2. Add dependency for volley library by adding following line in build.gradle file.


3. Add internet access permission in AndroidManifest.xml file.


4. Add following code in respective files.




Android Upload Image to Server Using Volley

You can ask your queries in comment section.

30 thoughts on “Android Upload Image to Server Using Volley

  1. salman hanfi

    I want to add 6 parametrs + base 64 image string hopw can i send with this logic

  2. karthik

    Got out of memory Error and
    E/WindowManager: Activity samplelink.imageuploadusingvolley.MainActivity has leaked window$DecorView{41f49648 V.E….. R……D 0,0-456,144} that was originally added here.

    Could you please help me to resolve this

  3. fandy

    And what if i want to upload file other than image ? (pdf,doc,excel dll) is this code work ?

  4. raja

    how to upload Multiple image using volley library in Single URL.

    1. Admin Post author

      In getParams() method you can use parameters.put() method to add more images.

  5. Kishor

    hi Neeraj,
    your code working but it throw error time of img upload

    “Some error occurred ->”

    can you help me how it can solve

  6. Arnold Azeem

    I get timed out error because the encoded String is too long. Can you help me solve this

  7. Shravan Manerikar

    getting timeout exception , rest code is same but only difference is i’m passing the image and some other data in json format as shown below

    protected Map getParams() throws AuthFailureError {
    Map params = new HashMap();
    params.put(“PartDetails”, json);

    return params;

    if i send it without selecting the image it works fine, but if i select an image then it throws timeout exception, but the entry gets uploaded in the database

  8. Karan Brahmaxatriya

    Some error occurred!
    please help me to solve this
    Thank you…

  9. pradeep

    hey bro
    i need a help. In my application i’m getting human signature . after that signature converted into image file on local memory. Then next i want to upload those image file by choose that images manually i ‘m want do those task . if there is any possibilities to directly upload those images into my database .

  10. Rahul jangid

    i want to upload image to server in android ,i use ‘com.theartofdev.edmodo:android-image-cropper:2.5.+’ library for cropping if i crop full image then upload it ,it give ” “, and if crop it small size and upload then it upload succesfully.

    please suggest some solution

  11. christy

    hey hi, String image is returning null in spring mvc

  12. christy

    public ResponseEntity documentUpload(HttpServletRequest request,HttpServletResponse response) throws Exception
    String image= request.getParameter(“image”);
    String image is returning null in spring mvc!!!

  13. Jilendra Singh

    My request is success but i am not getting response as i want. What is the Problem


Leave a Reply

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