Pick an Image from Android device and upload it to server using PHP



To upload an image from Android device to online server using PHP, first we need to create a PHP script to handle “post” request and store the image to a folder. So write this simple script on your server:

Make sure you have created a folder called “images” beside this script.

Then here is Java codes for Android:

To pick an image, call this function: “pickAnImage()” and to upload it call this one: “uploadToServer()”.

This source code is modified and simplified from original source in this link.

What about taking photo?

To take a photo, it’s just like picking an image. You just need to replace ACTION_GET_CONTENT with ACTION_IMAGE_CAPTURE and modify the request code. For more information, check out the codes related to this topic in this link: http://zofiakreasi.com/picking-an-image-and-taking-photo-in-android-java-source-code/



Published by

Habibie

Habibie is an Indonesian freelance frontend-backend web developer and cross platform mobile app programmer. He's also good at graphics design, video editing, visual effects and animation.

Leave a Reply

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