Android Upload Image Using PHP MySQL and Display Images in ListView

Hello friends welcome to our new Android Upload Image Using PHP MySQL Tutorial. I already published tutorials about how to upload image to server from android. But in last tutorial I stored android images to MySQL database. Now in this tutorial we won’t store image to MySQL database instead we will save our image inside a directory. So in this tutorial we will store image to a directory and the path of the image to our mysql database. And we will also fetch the stored image to our Android App. So lets begin.

Android Upload Image Using PHP MySQL Video

You can check out this video before moving ahead. This will show you that what you will be creating with this tutorial.

Making Your Server Ready for Image Upload

  • So we also need to create a database table this time. But this time we will store the path to the image in database. Create the following database
android upload image using php mysql
android upload image database
  • Now, in your server create a new directory. I created PhotoUpload
  • Inside the directory you need a script to connect to your database. So create a script name dbConnect.php and write the following code

  • Now you need one more script that will handle the photo upload. So I created a script named upload.php with the following code

  • Now the above script will handle uploads. It will store the images sent to a directory name uploads. So you also need to create a directory name uploads.
  • The above script will store the path to the images inside the MySQL database through which we will fetch all the images.
  • So we need one more image which will give the urls of all the images. For getting the urls we will use JSON.
  • Create a new script named getAllImages.php and write the following code

  • Now our server part is over. You can see below the snapshot of my server’s directory.
Android Upload Image Using PHP MySQL
Android Upload Image To Server Using PHP MySQL
  • I have the path of my upload.php and getAllImages.php script.
  • upload.php -> http://simplifiedcoding.16mb.com/PhotoUpload/upload.php
  • getAllImages.php -> http://simplifiedcoding.16mb.com/PhotoUpload/getAllImages.php

Creating Android Upload Image Using PHP MySQL Project

android upload image to server
Android Upload Image – Main Activity Layout
  • The following xml code will create the above layout

  • Create a new java class to handler our http request. I created RequestHandler.java

  • Now in the MainActivity.java write the following code to make the upload work.

  • Your app will now give you some error because we have not created new activity named ImageListView.class. You can comment this line for now.
  • Now add Internet permission to your manifest. Your upload image will work at this point.
  • Try running your app your image upload should work.
Android Upload Image Using PHP MySQL
Uploading Image
  • Now the lets move to the next part which is downloading uploaded images.

Showing Uploaded Images to a ListView in Android

The process I will be following here is good when you have to load few images. Because here we will be downloading all the images at once. And if you have 100s or 1000s images to show up on ListView, you should not follow this. So to make your list efficient check this tutorial here

Android Adding Items to List on Scroll

  • Uncomment your line which were causing error before. Now to remove this error we need to create a new Activity.
  • Create a blank activity. I just created ImageListView.
  • Now when we will click the View Image button this activity should open.
  • In this activity we will create a ListView. So come to the respective layout of this activity. (In my case it is activity_image_list_view.xml
  • We need to create the following layout
Android Upload Image Using PHP MySQL
Android Upload Image Using PHP MySQL
  • You can use the following xml code for creating above layout

  • Now we need to fetch all the Bitmaps from server. So for this we will create a new class. I created GetAlImages.java

  • We will pass the json string having all the urls of our images to the constructor of this class.
  • We will get the json string having all the urls from our getAllImages.php script.
  • Now come to ImageListView.java class and write the following code

  • Now we will create a new activity to see the full size image. I created ViewFullImage.java.
  • We will create a ImageView to the layout file of this activity.
Android Upload Image Using PHP MySQL
Android Fetch Image from Server
  • The xml code for the above layout is

  • Inside your java class for this layout write the following code

  • Now thats it. If you want the source code of this project you can download from here

[easy_media_download url=”https://dl.dropboxusercontent.com/s/697f4y7ah9x0wm0/android-upload-image-to-server-using-php-mysql.zip?dl=0″ text=”Download Source”]

So thats it for this Android Upload Image Using PHP MySQL Tutorial friends. If you are having confusions please leave you comments below.

180 thoughts on “Android Upload Image Using PHP MySQL and Display Images in ListView”

  1. Hi, thank You for this post, it’s very helpful.
    I have got one problem, how upload large image?
    What I sholud add to code ?

    Reply
  2. Hi, I can not cope with upload image and text to server 🙁 Can you show me or send to my email adress some example code?
    Please can You help me with this.

    Reply
  3. Hi Belal..this tutorial is excellent. But I want to use my captured image from camera to store in server. How can I do this using the same code.

    Reply
  4. Hi Belal,

    Can we write same code in using Volley library? I am using your same code, its working great but to upload 1MB it will response null after some time….

    Reply
  5. Salut Belal Khan merci pour tout ce que vous faite pour la communauté
    Pour mettre les images dans mysql sa marche mais quand j’essai de les récupérer a partir de la classe ViewImage sa ne marche pas l’application.

    Reply
  6. Belal Khan thank you to respond so quickly to my question. I said that I work on a local server with the phone here the error displayed on logcat:

    10-10 20:43:53.101 671-1265/? E/﹕ Could not open ‘/data/data/hotplug/cmd’
    10-10 20:43:53.101 671-1265/? E/﹕ error : 2, No such file or directory
    10-10 20:43:53.159 671-693/? E/﹕ Could not open ‘/data/data/hotplug/cmd’
    10-10 20:43:53.159 671-693/? E/﹕ error : 2, No such file or directory
    10-10 20:43:53.878 29109-29109/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: test.leviupload.com.leviupload, PID: 29109
    java.lang.NullPointerException
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:597)
    at test.leviupload.com.leviupload.CustomList.getView(CustomList.java:39)
    at android.widget.AbsListView.obtainView(AbsListView.java:2358)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1273)
    at android.widget.ListView.onMeasure(ListView.java:1182)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
    at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:124)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5374)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2337)
    at android.view.View.measure(View.java:16842)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2246)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1312)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1509)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1189)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6223)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
    at android.view.Choreographer.doCallbacks(Choreographer.java:591)
    at android.view.Choreographer.doFrame(Choreographer.java:560)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5292)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
    at dalvik.system.NativeStart.main(Native Method)
    10-10 20:43:54.540 671-693/? E/﹕ Could not open ‘/data/data/hotplug/cmd’
    10-10 20:43:54.540 671-693/? E/﹕ error : 2, No such file or directory
    10-10 20:43:54.645 981-981/? E/Hotseat﹕ onResume on
    10-10 20:43:54.679 981-981/? E/Hotseat﹕ onResume off
    10-10 20:43:54.768 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:54.768 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:54.787 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:54.959 142-23300/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:54.963 142-23300/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:54.963 142-23300/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:54.970 981-981/? E/liuwei﹕ resetLayout
    10-10 20:43:54.973 142-23300/? E/FileSourceProxy﹕ Open dupFd fail for file /data/media/Recording/record20150908182351.aac
    10-10 20:43:54.979 142-23300/? E/FileSourceProxy﹕ Open dupFd fail for file /data/media/Recording/record20150908182351.aac
    10-10 20:43:55.010 142-29580/? E/MtkOmxAudioDecBase﹕ MtkOmxAudioDecBase:SetParameter unsupported nParamIndex(0x7F00001E)
    10-10 20:43:55.011 142-29580/? E/OMXCodec﹕ @@ [OUT] def.nBufferSize = 24576
    10-10 20:43:55.011 142-29580/? E/OMXCodec﹕ @@ [OUT] totalSize = 221696
    10-10 20:43:55.071 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.071 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.071 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.072 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.073 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =144
    10-10 20:43:55.103 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.104 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.121 142-142/? E/MetadataRetrieverClient﹕ failed to extract an album art
    10-10 20:43:55.129 16607-16618/? E/MediaProvider﹕ openFile: failed! uri=content://media/external/audio/albumart/17, mode=r
    10-10 20:43:55.132 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*144
    10-10 20:43:55.179 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.179 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.183 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.183 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.187 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.188 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.188 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =144
    10-10 20:43:55.190 142-729/? E/MetadataRetrieverClient﹕ failed to extract an album art
    10-10 20:43:55.192 16607-17386/? E/MediaProvider﹕ openFile: failed! uri=content://media/external/audio/albumart/17, mode=r
    10-10 20:43:55.193 29554-29554/? E/MusicUtils﹕ getArtworkFromFile: FileNotFoundException!
    10-10 20:43:55.194 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*144
    10-10 20:43:55.245 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.245 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.250 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.272 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.272 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.278 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.282 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.283 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.284 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.285 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.289 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.289 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.295 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.295 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.296 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.297 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.298 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.299 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.300 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.311 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.313 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.314 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.315 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.316 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.317 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.318 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.325 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.327 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.329 671-965/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.376 29554-29554/? E/MediaPlayer﹕ Should have subtitle controller already set
    10-10 20:43:55.427 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.427 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.443 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.446 981-981/? E/MusicControl﹕ onServiceConnected
    10-10 20:43:55.457 671-693/? E/﹕ Could not open ‘/data/data/hotplug/cmd’
    10-10 20:43:55.457 671-693/? E/﹕ error : 2, No such file or directory
    10-10 20:43:55.498 142-729/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.498 142-729/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.498 142-729/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.498 142-729/? E/FileSourceProxy﹕ Open dupFd fail for file /data/media/Recording/Anam(1-25).aac
    10-10 20:43:55.499 142-729/? E/FileSourceProxy﹕ Open dupFd fail for file /data/media/Recording/Anam(1-25).aac
    10-10 20:43:55.506 142-29609/? E/MtkOmxAudioDecBase﹕ MtkOmxAudioDecBase:SetParameter unsupported nParamIndex(0x7F00001E)
    10-10 20:43:55.507 142-29609/? E/OMXCodec﹕ @@ [OUT] def.nBufferSize = 24576
    10-10 20:43:55.507 142-29609/? E/OMXCodec﹕ @@ [OUT] totalSize = 221696
    10-10 20:43:55.508 29554-29554/? E/MediaPlayer﹕ Should have subtitle controller already set
    10-10 20:43:55.515 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.515 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.526 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.526 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.526 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =144
    10-10 20:43:55.528 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*144
    10-10 20:43:55.591 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.591 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.595 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.596 142-142/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:55.596 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.602 142-729/? E/MetadataRetrieverClient﹕ failed to extract an album art
    10-10 20:43:55.603 16607-17386/? E/MediaProvider﹕ openFile: failed! uri=content://media/external/audio/albumart/17, mode=r
    10-10 20:43:55.617 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.617 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.621 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.642 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.642 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.646 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.689 981-981/? E/test﹕ updateItemInDatabaseHelper start
    10-10 20:43:55.690 981-981/? E/test﹕ updateItemInDatabaseHelper start
    10-10 20:43:55.710 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.710 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.714 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.725 671-967/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.731 671-707/? E/InputDispatcher﹕ channel ’42abb848 test.leviupload.com.leviupload/test.leviupload.com.leviupload.ImageListView (server)’ ~ Channel is unrecoverably broken and will be disposed!
    10-10 20:43:55.749 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.749 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.752 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.768 671-878/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:55.834 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.834 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.842 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.862 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.862 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:43:55.863 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:43:55.957 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.957 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.958 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.958 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.959 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.959 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.960 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.960 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.961 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.961 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.963 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:55.963 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:55.964 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:55.964 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =678
    10-10 20:43:55.965 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*678
    10-10 20:43:55.966 981-981/? E/liuwei﹕ ++++++++++ i=2
    10-10 20:43:55.966 981-981/? E/liuwei﹕ ++++++++++ i=3
    10-10 20:43:55.966 981-981/? E/liuwei﹕ ++++++++++ i=4
    10-10 20:43:55.966 981-981/? E/liuwei﹕ ————– i= 0
    10-10 20:43:56.002 981-981/? E/liuwei﹕ ————– i= 1
    10-10 20:43:56.144 981-981/? E/liuwei﹕ ————– i= 5
    10-10 20:43:56.172 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.172 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.173 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.173 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.174 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.174 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.175 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.175 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.176 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.176 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.177 981-981/? E/liuwei6﹕ mOriginalCellWidth 114
    10-10 20:43:56.177 981-981/? E/liuwei﹕ setCellDimensions mCellWidth=114mCellHeight=128
    10-10 20:43:56.177 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:43:56.177 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =678
    10-10 20:43:56.178 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*678
    10-10 20:43:56.179 981-981/? E/liuwei﹕ ++++++++++ i=2
    10-10 20:43:56.179 981-981/? E/liuwei﹕ ++++++++++ i=3
    10-10 20:43:56.179 981-981/? E/liuwei﹕ ++++++++++ i=4
    10-10 20:43:56.179 981-981/? E/liuwei﹕ ————– i= 0
    10-10 20:43:56.212 981-981/? E/liuwei﹕ ————– i= 1
    10-10 20:43:56.344 981-981/? E/liuwei﹕ ————– i= 5
    10-10 20:43:56.369 981-981/? E/liuwei3﹕ enableHwLayersOnVisiblePages leftScreen rightScreen=3*4
    10-10 20:43:57.860 142-728/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:57.860 142-728/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:57.865 142-23300/? E/MetadataRetrieverClient﹕ failed to extract an album art
    10-10 20:43:57.866 16607-16618/? E/MediaProvider﹕ openFile: failed! uri=content://media/external/audio/albumart/17, mode=r
    10-10 20:43:57.874 142-728/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:57.874 142-728/? E/DrmMtkUtil/DrmUtil﹕ checkDcf: not dcf type, dcf version value [255]
    10-10 20:43:57.879 142-23300/? E/MetadataRetrieverClient﹕ failed to extract an album art
    10-10 20:43:57.880 16607-16685/? E/MediaProvider﹕ openFile: failed! uri=content://media/external/audio/albumart/17, mode=r
    10-10 20:43:57.880 29554-29554/? E/MusicUtils﹕ getArtworkFromFile: FileNotFoundException!
    10-10 20:43:57.891 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.892 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.893 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.894 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.894 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.895 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.896 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.897 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.898 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.899 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.900 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.901 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.902 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.903 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.904 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.905 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.906 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.907 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.908 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:43:57.909 671-2439/? E/RemoteViews﹕ ANR Warning,RemoteViews can only be used once ,if not ,it may cause ANR in hosts such as Laucher,SystemUI. keys for search
    10-10 20:44:00.025 981-981/? E/LIUWEI﹕ ACTION_TIME_TICK
    10-10 20:44:00.062 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:44:00.062 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:44:00.063 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:44:00.078 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:44:00.078 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:44:00.080 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:44:00.095 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:44:00.095 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:44:00.096 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640
    10-10 20:44:00.111 981-981/? E/liuwei﹕ pageview widthMode =1073741824widthSize =480
    10-10 20:44:00.111 981-981/? E/liuwei﹕ pageview heightMode =1073741824heightSize =640
    10-10 20:44:00.112 981-981/? E/liuwei﹕ pageview measure widthSize *heightSize =480*640

    Reply
  7. Bro, this program only will upload .png file ? is it possible to upload jpeg file ? If my application want to take picture and upload, how to make it ??

    Reply
    • This code will also upload jpg images.. But it will change the jpg extension to png. So you have to send one more parameter to the server as file type and save the file with the appropriate extension..

      Reply
      • Currently, I am able to upload my printscreen image and the image downloaded from somewhere.
        But I upload the photo that taken by my phone, it is not able to upload successfully. In the server there, it’s show 0 size of that image. Do you know how come like this ?
        I tried the downloaded image size is bigger than taken image, no problem for uploading.
        I am very new beginner. Thank you very much.

        Reply
          • But my photo is only 800kb, and I success to upload a photo which size is 900kb(the photo is downloaded by somewhere).

          • Haha, I try to use front-camera and with lower size of image, it successfully upload. Thanks and wait for your new tutorial.
            Have a nice day.

        • I have same problem. I took captured images and it shows http:\/\/plantnow.net16.net\/ uploadedimages\/25.jpeg null

          “null” .If you got answer pl help me!

          Reply
          • bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);

            change to

            bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);

  8. Hello i hope you see this message fast 🙁 i get this error:

    java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.graphics.Bitmap.getWidth()’ on a null object reference

    the uploading work with me BUT when i click on “View Image” it get this error above

    Reply
  9. Dear Sir.

    Please help me, i get this error when i am trying to view an image from activity_view_image

    10-25 12:40:18.251 1295-1306/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@ebce8f0 attribute=null, token = android.os.BinderProxy@d39be1

    the image is stored as varchar like your tourtiual http://www.simplifiedcoding.net/android-upload-image-using-php-mysql-android-studio/

    Reply
  10. I success to upload the photo to server, but I fail to download. After I press the ‘view image’ button, it is showing downloading and then the app is forced to close.
    Here is the error message “ava.lang.NullPointerException: Attempt to invoke virtual method ‘int android.graphics.Bitmap.getWidth()’ on a null object reference”
    Anyone know how to fix it ?

    Reply
  11. I want an coding for uploading txt files like pdf,ppt etc…, to the mysql from android and to fetch those stuffs as well…
    I am jst running out of tym…as much as possibel try to upload things regarding this bro…
    would b happy if i get reply for it… 🙂

    Reply
  12. how do i resolved the import android.support.v7.app.AppCompatActivity. I am trying many tutorial but can’t add this library.

    Reply
  13. Hello Belal, first of all thanks a lot for your tutorial!
    I have got an issue….I replaced the listView with a gridView, but i guess is exactly the same (making proper adjustment to the code). Anyway when i download the list of images from the server (I checked are properly uploaded..) and i try to display them in the gridView the gridView is empty! Do you have any idea off what’s going on?
    Thanks a lot!

    Reply
  14. Thanks Belal, I get the url loaded properly on the database but the image is not uploaded to the server folder. Any idea what went wrong?

    Reply
  15. sir i want to fetch image along with text data and show it in listview after login or simply giving by id sir how can i do this. please post a tutorial or help in some other way.

    Reply
  16. I am always getting this error…. java.lang.NullPointerException
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:482)
    at net.simplifiedcoding.imageuploadsample.CustomList.getView(CustomList.java:36)

    there is some problem with this line image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));

    can you please help me?

    Reply
  17. Hi , Belal Khan
    i used ur upload code but occur this error

    W/EGL_emulation: eglSurfaceAttrib not implemented
    W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabe7fb00, error=EGL_SUCCESS
    E/Surface: getSlotFromBufferLocked: unknown buffer: 0xab75d510

    can u teach me how to solve this ?

    A million thanks =)

    Reply
  18. Hello i can do all things and create all file but i cant under stand php files i request u please give me a php files.

    Reply
  19. I have this problem
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: Process: net.simplifiedcoding.imageuploadsample, PID: 2223
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:300)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.lang.Thread.run(Thread.java:841)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: Caused by: java.lang.NullPointerException
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at net.simplifiedcoding.imageuploadsample.GetAlImages.getAllImages(GetAlImages.java:56)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at net.simplifiedcoding.imageuploadsample.ImageListView$1GetImages.doInBackground(ImageListView.java:66)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at net.simplifiedcoding.imageuploadsample.ImageListView$1GetImages.doInBackground(ImageListView.java:46)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:288)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
    01-18 01:29:11.820 2223-2544/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: at java.lang.Thread.run(Thread.java:841) 
    01-18 01:29:11.880 2223-2223/net.simplifiedcoding.imageuploadsample W/EGL_emulation: eglSurfaceAttrib not implemented
    01-18 01:29:13.540 2223-2544/? I/Process: Sending signal. PID: 2223 SIG: 9

    how to fixed it??

    Reply
  20. it gives me like

    Warning:file_put_contents(23.png): failed to open Stream : Permission denied in C:\InetPub\vhosts\websitename.com\httpdocs\new.php on line 28Successfully Uploaded.

    i am not be able to see my images at specific location where i stored the image.

    Reply
  21. hi my app show upload sccucessful. but i cant have anything in my database .
    in logcat the error is sendUserActionEvent()=null
    pls help

    Reply
  22. i try your code is good sucess

    just button viewImage

    download of server

    force stop this program please help me

    thanks about allthing

    Reply
  23. Hello sir Belal, I am getting this error:

    java.lang.NullPointerException
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java)
    at net.simplifiedcoding.imageuploadsample.CustomList.getView(CustomList.java:37)

    which is this line image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));

    the images are uploaded to the server, i am using hostinger. can you please help me? Hoping for your response

    Reply
  24. Hello i succeded to upload the photo to mysql server, i want now to make a list of images that i uploaded and their names.but you said that “if you have 100s or 1000s images to show up on ListView, you should not follow this”
    what can be the suitable solution for this problem??

    Reply
  25. $actualpath = “http://simplifiedcoding.16mb.com/PhotoUpload/$path”;*/
    should i include your path of put my real path ? as below
    $actualpath = “C:\xampp\htdocs\PhotoUpload\$path”;

    Reply
  26. i want to display one image in image view don’t want to use list view and all..
    php will display like this using json {“result”:[{“product_name”:”mural”,”product_desc”:”mural”,”category_name”:”HOME MADE PRODUCTS”,”seller_price”:”6000″,”max_price”:”12000″,”image”:”http:\/\/bidkarde.16mb.com\/bidkarde\/images\/15.png”}]} how can i display this single image

    Reply
  27. how to display single image if my php is: {“result”:[{“product_name”:”mural”,”product_desc”:”mural”,”category_name”:”HOME MADE PRODUCTS”,”seller_price”:”600″,”max_price”:”1200″,”image”:”http:\/\/bidkarde.16mb.com\/bidkarde\/images\/19.png”}]}

    Reply
  28. 03-10 11:19:29.241 2064-2064/com.example.administrator.fetchimage I/art: Not late-enabling -Xcheck:jni (already on)
    03-10 11:19:29.832 2064-2076/com.example.administrator.fetchimage I/art: Background sticky concurrent mark sweep GC freed 3288(304KB) AllocSpace objects, 0(0B) LOS objects, 20% free, 890KB/1117KB, paused 1.004ms total 157.752ms
    03-10 11:19:30.559 2064-2064/com.example.administrator.fetchimage I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread.
    03-10 11:19:30.560 2064-2064/com.example.administrator.fetchimage D/gralloc_goldfish: Emulator without host-side GPU emulation detected.
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage D/AndroidRuntime: Shutting down VM
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: FATAL EXCEPTION: main
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: Process: com.example.administrator.fetchimage, PID: 2064
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method ‘int java.lang.String.length()’ on a null object reference
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at org.json.JSONTokener.nextValue(JSONTokener.java:94)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at org.json.JSONObject.(JSONObject.java:156)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at org.json.JSONObject.(JSONObject.java:173)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at com.example.administrator.fetchimage.GetAlImages.(GetAlImages.java:30)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at com.example.administrator.fetchimage.ImageListView$1GetURLs.onPostExecute(ImageListView.java:86)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at com.example.administrator.fetchimage.ImageListView$1GetURLs.onPostExecute(ImageListView.java:73)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:636)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.os.AsyncTask.access$500(AsyncTask.java:177)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5254)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    03-10 11:19:30.774 2064-2064/com.example.administrator.fetchimage E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    03-10 11:19:35.469 2064-2064/com.example.administrator.fetchimage I/Process: Sending signal. PID: 2064 SIG: 9

    Reply
  29. I want to store some description with image to server. but it shows as error. how can i upload text and image to server.

    Reply
  30. Salam brother..!!
    Thanks 4 an empressive tutorial..!!
    i am facing a minner issue. when i click view image button i face this error.
    plz help me quickly. its urgent..!!
    thanks again..

    03-14 09:54:49.046 13493-13493/net.simplifiedcoding.imageuploadsample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: net.simplifiedcoding.imageuploadsample, PID: 13493
    java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.graphics.Bitmap.getWidth()’ on a null object reference
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:596)
    at net.simplifiedcoding.imageuploadsample.CustomList.getView(CustomList.java:36)

    Reply
  31. Hi Belal,
    When i try to click on view Images it gives me error application has stopped working.
    Can you please help me with this..
    Thanks & Regards,
    Avinash Yadav

    Reply
  32. hello, congratulations for your guides. I save the images in blob format, is possibile print it into a listview? or is necessary follow this guide? Thanks

    Reply
  33. Hi Belal,
    I have tried your code image is getting uploaded to the uploads directory properly but when i try to fetch the image it showing following error in log. Please provide the solution.

    04-07 09:45:45.542 4424-4424/com.example.avi.imageuploaddownload W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    04-07 09:45:45.561 4424-5392/com.example.avi.imageuploaddownload E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #3
    Process: com.example.avi.imageuploaddownload, PID: 4424
    java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:304)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘int org.json.JSONArray.length()’ on a null object reference
    at com.example.avi.imageuploaddownload.GetAlImages.getAllImages(GetAlImages.java:56)
    at com.example.avi.imageuploaddownload.ImageListView$1GetImages.doInBackground(ImageListView.java:64)
    at com.example.avi.imageuploaddownload.ImageListView$1GetImages.doInBackground(ImageListView.java:44)
    at android.os.AsyncTask$2.call(AsyncTask.java:292)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                at java.lang.Thread.run(Thread.java:818)
    04-07 09:45:45.614 4424-4442/com.example.avi.imageuploaddownload W/EGL_emulation﹕ eglSurfaceAttrib not implemented
    04-07 09:45:45.614 4424-4442/com.example.avi.imageuploaddownload W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3fcda60, error=EGL_SUCCESS
    04-07 09:45:45.933 4424-4442/com.example.avi.imageuploaddownload W/EGL_emulation﹕ eglSurfaceAttrib not implemented
    04-07 09:45:45.933 4424-4442/com.example.avi.imageuploaddownload W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xf3fcda60, error=EGL_SUCCESS
    04-07 09:45:46.288 4424-4424/com.example.avi.imageuploaddownload E/WindowManager﹕ android.view.WindowLeaked: Activity com.example.avi.imageuploaddownload.ImageListView has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{28fccb77 V.E….. R……D 0,0-729,322} that was originally added here
    at android.view.ViewRootImpl.(ViewRootImpl.java:363)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
    at android.app.Dialog.show(Dialog.java:298)
    at android.app.ProgressDialog.show(ProgressDialog.java:116)
    at android.app.ProgressDialog.show(ProgressDialog.java:104)
    at com.example.avi.imageuploaddownload.ImageListView$1GetImages.onPreExecute(ImageListView.java:49)
    at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:591)
    at android.os.AsyncTask.execute(AsyncTask.java:539)
    at com.example.avi.imageuploaddownload.ImageListView.getImages(ImageListView.java:73)
    at com.example.avi.imageuploaddownload.ImageListView.access$000(ImageListView.java:26)
    at com.example.avi.imageuploaddownload.ImageListView$1GetURLs.onPostExecute(ImageListView.java:92)
    at com.example.avi.imageuploaddownload.ImageListView$1GetURLs.onPostExecute(ImageListView.java:77)
    at android.os.AsyncTask.finish(AsyncTask.java:636)
    at android.os.AsyncTask.access$500(AsyncTask.java:177)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    04-07 09:45:50.130 4424-5392/com.example.avi.imageuploaddownload I/Process﹕ Sending signal. PID: 4424 SIG: 9

    c
    Thanks & Regards,
    Avinash Yadav
    avinashsy143@gmail.com

    Reply
  34. Hi Belal,

    When i try to upload image it shows blank toast.
    The path is stored in table, but image is not stored in uploads directory.
    what I have to do now? plz give the rply.

    Reply
  35. hello sir, is there any tutorial on, uploading audio files and downloading it as well? the same concept of using php and mysql, but with additional param or fields on the database, e.g, filename, date and time, etc? please, need it so badly.

    Reply
  36. thank u soo much,u r code is working perfectly
    can u give me tutorial login and registration with out volley ,thats connects to hosinger
    thanks in advance for ur effort

    Reply
  37. Hi i am able to run this code successfully… but there is one small issue i noticed…it gives me memory error if i choose a bigger file say 2M..

    java.lang.OutOfMemoryError

    How to avoid this ?

    Thanks in advance

    Reply
  38. Hi Belal.while I’m pressing view image button the application get crashed.the error occurs

    Error:

    Process: net.simplifiedcoding.imageuploadsample, PID: 7178
    java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.graphics.Bitmap.getWidth()’ on a null object reference
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:591)
    at net.simplifiedcoding.imageuploadsample.CustomList.getView(CustomList.java:36)
    at android.widget.AbsListView.obtainView(AbsListView.java:2467)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1286)

    plz tell me how to slove this error……………..

    Reply
  39. Bilal i have followed your tutorial on google map….

    How to draw path while device moving… its urgent please help me….

    Thank you..

    Reply
  40. how to give path for directory present on localhost..
    public static final String UPLOAD_URL = “http://10.0.2.2/PhotoUpload/upload”;..is this correct???

    Reply
  41. Hi Belal,

    I was implementing u r code to upload the image to the server … when i run the php script from my app i get an error.
    My php script is in
    http://www.aaa.com/test
    and I want to upload the image to http://www.aaa.com/test/photos.
    The image gets decoded properly but below code gives an error
    file_put_contents($path,base64_decode($image));

    what should i put as the path path name and why am i getting this error ?
    My app is stuck because of this …
    help …

    Thanks
    sohan

    Reply
  42. hey…along with the image I also need to upload its description…I have added edittext and I have also added a new String parameter to SendPostRequestMethod…but description is still not getting saved in database…
    I have also made some changes in upload.php like:
    $description = $_POST[‘description’];
    $sql = “INSERT INTO books (image,description) VALUES (‘$actualpath’,’$description’)”;

    Do I need to make some other changes???
    Plz help

    Reply
  43. hello….i have a problem…my images are getting uploaded successfully…But then, when i click on view image …i get the message “unfortunately, project has stopped.” I dont know where the problem is..?
    i have added permissions of all my java file in my manifest file and also when i run the path of getAllImages.php in my browser, i am able to get the json code…..then where lies the problem????
    Please help…
    Thank you

    Reply
  44. hi dear tried you code several time but is not working .. it very thankful to you if you send me complete project with php file i really need it i tried many time your and other code and my own logic but i couldn’t do this so please help me it been very thankful to you …

    Reply
  45. Hi,

    I getting on error on uploading image.
    I get a hmtl feedback mysqli_fetch_array requires one parameter to be a boolean resource.

    Kindly help,

    Ronoh.

    Reply
  46. am getting an error when i run the upload.php file…which path should i use?yours or mine…$actualpath = “http://localhost/photoupload/$path”;

    Reply
  47. Hello Sir Bel. I can upload the Picture but i can’t view the list. Can you help me with this problem? Please. Hope you can hear my problem.

    Reply
  48. this code is working properly but save image in folder is corrupt plz help me
    if any CAPTCHA Code tutorial in android send me

    Reply
  49. hi bro please help me .while I’m pressing view image button the application get crashed.the error occurs

    Error:

    Process: net.simplifiedcoding.imageuploadsample, PID: 7178
    java.lang.NullPointerException: Attempt to invoke virtual method ‘int android.graphics.Bitmap.getWidth()’ on a null object reference
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:591)
    at net.simplifiedcoding.imageuploadsample.CustomList.getView(CustomList.java:36)
    at android.widget.AbsListView.obtainView(AbsListView.java:2467)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1286)

    plz tell me how to slove this error……………..

    Reply
  50. Hi Belal, this is working fine for small images but the images more than 500 KB are not uploading, after showing uploading message in loader, a null Toast shown. what to do for uploading images those are in MBs.

    Reply
  51. Android Upload Image Using PHP MySQL and Display Images in ListView
    how to download free source code bcoz download source button not download code .
    so please help me. your source are very helpful but some error after running application; i click on choose file button but not take images.

    Reply
  52. Belal
    I want to display image from php to android along with name and price detail having next and previous buttons.
    Can you please help me

    Reply
  53. hello great tutorial belal.

    here m getting same error in CustomList.java

    this is logcat error : image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));
    unable to find whats the error

    Reply
  54. hello great tutorial belal.

    here m getting same error in CustomList.java

    this is logcat error : image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));

    unable to find whats the error

    Reply
  55. Hello , Thanks for tutorial,
    how to save image into MySQL database as blob data type by using android…please help how to change into this code…
    Thanks in advanced…………..!

    Reply
  56. How can i get a response on the device screen like a toast, when the picture was or wasn’t inserted properly.
    Thanks. Hope you reply! 🙂

    Reply
  57. Broo i want to get one image in image view intead of listview …what is the android code for that.. can you tell me please..reply

    Reply
  58. Bro, this code works fine for me but to retrieve images from server it doesn’t show anything once i close my app and then open app again it show the images it takes more than 5 minutes i don’t know why this delay happening please guide me

    Reply
  59. Can u please provide code for directly capturing picture from android application and storing in database???
    Please reply at earliest

    Reply
  60. Hello sir I use your code in my project and it works good but i have another problem. i firstly insert images in sqlite and upload them. when i select images from sqlite but i couldn’t upload them.
    Please help me. Thank you

    Reply
  61. REALLY GOOG TUTORIAL!! Works Perfect.. just one question, if I have another column named : “name” that stores the images name, how could i change when i download the images to show the name instead of the url on the image list view?Thanks

    Reply
  62. Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
    at com.ranstal.vellalarmatrimony.Uploadimage$1UploadImage.doInBackground(Uploadimage.java:111)
    at com.ranstal.vellalarmatrimony.Uploadimage$1UploadImage.doInBackground(Uploadimage.java:91)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
    at java.lang.Thread.run(Thread.java:764) 
    this error is occured while execute my program …please help me

    Reply
  63. Haiii Good Afternoon,
    Am Ashok and new to android developer.
    Recently, i joined in software company as per android app developer.
    We have any android tutorials please send to my email (a.koda59@gmail.com).
    Present iam doing inventory project and this my first project.
    Your tutorial is very useful to me and thanks for this tutorial.
    Finally i have a small doubt, how to connect common database (MYSQL) to android project and web application.

    Reply

Leave a Comment