Ad

How To Upload Multiple Selected Files (i.e..doc,pdf,jpeg,png) In Server At Android

In android,how to select multiple files from file manager. After will shown the details of the image(i.e. image size,image name and delete the files). Then how to upload that files to server.

Ad

Answer

You can do this by using Multi Part data upload and You can add multiple files in single array.

If you are using Retrofit then please check this Android Upload Multiple Files In A Single Request Or which library you are using for api call?

Yes you can see files[0], files[1] means they are only uploading two files at a time. here you can use loop to upload number of selected types.

ArrayList<String> listImages = new ArrayList();

Let's say you have to upload 10 files and all path is in arrylist.

for(int i = 0 ; i < listImages.size() ; i++ ){
    params.put("files[" + i + "]", MultipartBody.create(mediaType, new File("First file path")));
}

Hope this help :)

Ad
source: stackoverflow.com
Ad