Android

Image upload on server using android Retrofit 2 Library

Retrofit

Image upload on server using android Retrofit 2 Library

First we need to prepare our client server for our app.

To do that follow below step

  • Create a folder name it retrofit_tutorial and inside it create another name it uploads
  • In retrofit_tutorial folder create a file name it retrofit_client or any name you want
  • In that php file insert this below code
Create a new project and add this below lines to your app level gradle file.
Add this following line of codes in your manifest file
Create a class name it ApiClient and paste the below code
 

Create a interface called ApiService and add the following below code

Now we need to create a model class using by retrofit library. This used to receive server response. Here variable name will be same as we define in client server code. (success and message)

Create activity_main.xml and Paste the following lines

Create MainActivity.java and Paste the following lines

 

After selecting on of my pick from my mobile

retrofit 2

 

After Uploading

Retrofit 2

 

Note:

If your server upload limit is 2M you can’t upload more than that. Please make sure your server accept more than 2 mb file size

Leave a Reply

Your email address will not be published.

eleven + 6 =