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

- 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
1 2 3 4 5 6 7 8 9 | <?php define('HOST','mysql.hostinger.in'); define('USER','u502452270_andro'); define('PASS','belal_123'); define('DB','u502452270_andro'); $con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect'); |
- Now you need one more script that will handle the photo upload. So I created a script named upload.php with the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <?php if($_SERVER['REQUEST_METHOD']=='POST'){ $image = $_POST['image']; require_once('dbConnect.php'); $sql ="SELECT id FROM photos ORDER BY id ASC"; $res = mysqli_query($con,$sql); $id = 0; while($row = mysqli_fetch_array($res)){ $id = $row['id']; } $path = "uploads/$id.png"; $actualpath = "http://simplifiedcoding.16mb.com/PhotoUpload/$path"; $sql = "INSERT INTO photos (image) VALUES ('$actualpath')"; if(mysqli_query($con,$sql)){ file_put_contents($path,base64_decode($image)); echo "Successfully Uploaded"; } mysqli_close($con); }else{ echo "Error"; } |
- 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php require_once('dbConnect.php'); $sql = "select image from photos"; $res = mysqli_query($con,$sql); $result = array(); while($row = mysqli_fetch_array($res)){ array_push($result,array('url'=>$row['image'])); } echo json_encode(array("result"=>$result)); mysqli_close($con); |
- Now our server part is over. You can see below the snapshot of my server’s directory.

- 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
- Open Android Studio and Create a New Android Project
- This part is same as we did before in how to upload image from android
- You need to create the following layout

- The following xml code will create the above layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/string_choose_file" android:id="@+id/buttonChoose" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/imageView" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/string_upload_image" android:id="@+id/buttonUpload" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/string_view_image" android:id="@+id/buttonViewImage" /> </LinearLayout> |
- Create a new java class to handler our http request. I created RequestHandler.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | package net.simplifiedcoding.imageuploadsample; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import javax.net.ssl.HttpsURLConnection; /** * Created by Belal on 8/19/2015. */ public class RequestHandler { public String sendPostRequest(String requestURL, HashMap<String, String> postDataParams) { URL url; StringBuilder sb = new StringBuilder(); try { url = new URL(requestURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(15000); conn.setConnectTimeout(15000); conn.setRequestMethod("POST"); conn.setDoInput(true); conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(os, "UTF-8")); writer.write(getPostDataString(postDataParams)); writer.flush(); writer.close(); os.close(); int responseCode = conn.getResponseCode(); if (responseCode == HttpsURLConnection.HTTP_OK) { BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); sb = new StringBuilder(); String response; while ((response = br.readLine()) != null){ sb.append(response); } } } catch (Exception e) { e.printStackTrace(); } return sb.toString(); } private String getPostDataString(HashMap<String, String> params) throws UnsupportedEncodingException { StringBuilder result = new StringBuilder(); boolean first = true; for (Map.Entry<String, String> entry : params.entrySet()) { if (first) first = false; else result.append("&"); result.append(URLEncoder.encode(entry.getKey(), "UTF-8")); result.append("="); result.append(URLEncoder.encode(entry.getValue(), "UTF-8")); } return result.toString(); } } |
- Now in the MainActivity.java write the following code to make the upload work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | package net.simplifiedcoding.imageuploadsample; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.AsyncTask; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Base64; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; public class MainActivity extends AppCompatActivity implements View.OnClickListener { public static final String UPLOAD_URL = "http://simplifiedcoding.16mb.com/PhotoUpload/upload.php"; public static final String UPLOAD_KEY = "image"; private int PICK_IMAGE_REQUEST = 1; private Button buttonChoose; private Button buttonUpload; private Button buttonView; private ImageView imageView; private Bitmap bitmap; private Uri filePath; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonChoose = (Button) findViewById(R.id.buttonChoose); buttonUpload = (Button) findViewById(R.id.buttonUpload); buttonView = (Button) findViewById(R.id.buttonViewImage); imageView = (ImageView) findViewById(R.id.imageView); buttonChoose.setOnClickListener(this); buttonUpload.setOnClickListener(this); buttonView.setOnClickListener(this); } private void showFileChooser() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { filePath = data.getData(); try { bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath); imageView.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } } } public String getStringImage(Bitmap bmp){ ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); return encodedImage; } private void uploadImage(){ class UploadImage extends AsyncTask<Bitmap,Void,String>{ ProgressDialog loading; RequestHandler rh = new RequestHandler(); @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this, "Uploading...", null,true,true); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); loading.dismiss(); Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show(); } @Override protected String doInBackground(Bitmap... params) { Bitmap bitmap = params[0]; String uploadImage = getStringImage(bitmap); HashMap<String,String> data = new HashMap<>(); data.put(UPLOAD_KEY, uploadImage); String result = rh.sendPostRequest(UPLOAD_URL,data); return result; } } UploadImage ui = new UploadImage(); ui.execute(bitmap); } @Override public void onClick(View v) { if (v == buttonChoose) { showFileChooser(); } if(v == buttonUpload){ uploadImage(); } if(v == buttonView){ viewImage(); } } private void viewImage() { startActivity(new Intent(this, ImageListView.class)); } } |
- 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.

- 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
- 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

- You can use the following xml code for creating above layout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="net.simplifiedcoding.imageuploadsample.ImageListView"> <ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/listView" /> </LinearLayout> |
- We have to create a Custom List View for so we will create a new xml resource file for our Custom List View.
- I created image_list_view.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/imageDownloaded" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/abc_ic_menu_copy_mtrl_am_alpha"/> <TextView android:id="@+id/textViewURL" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> |
- Now create a new class named CustomList for our Custom List View.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package net.simplifiedcoding.imageuploadsample; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; /** * Created by Belal on 7/22/2015. */ public class CustomList extends ArrayAdapter<String> { private String[] urls; private Bitmap[] bitmaps; private Activity context; public CustomList(Activity context, String[] urls, Bitmap[] bitmaps) { super(context, R.layout.image_list_view, urls); this.context = context; this.urls= urls; this.bitmaps= bitmaps; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); View listViewItem = inflater.inflate(R.layout.image_list_view, null, true); TextView textViewURL = (TextView) listViewItem.findViewById(R.id.textViewURL); ImageView image = (ImageView) listViewItem.findViewById(R.id.imageDownloaded); textViewURL.setText(urls[position]); image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false)); return listViewItem; } } |
- Now we need to fetch all the Bitmaps from server. So for this we will create a new class. I created GetAlImages.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | package net.simplifiedcoding.imageuploadsample; import android.app.ProgressDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; /** * Created by Belal on 9/19/2015. */ public class GetAlImages { public static String[] imageURLs; public static Bitmap[] bitmaps; public static final String JSON_ARRAY="result"; public static final String IMAGE_URL = "url"; private String json; private JSONArray urls; public GetAlImages(String json){ this.json = json; try { JSONObject jsonObject = new JSONObject(json); urls = jsonObject.getJSONArray(JSON_ARRAY); } catch (JSONException e) { e.printStackTrace(); } } private Bitmap getImage(JSONObject jo){ URL url = null; Bitmap image = null; try { url = new URL(jo.getString(IMAGE_URL)); image = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return image; } public void getAllImages() throws JSONException { bitmaps = new Bitmap[urls.length()]; imageURLs = new String[urls.length()]; for(int i=0;i<urls.length();i++){ imageURLs[i] = urls.getJSONObject(i).getString(IMAGE_URL); JSONObject jsonObject = urls.getJSONObject(i); bitmaps[i]=getImage(jsonObject); } } } |
- 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | package net.simplifiedcoding.imageuploadsample; import android.app.ProgressDialog; import android.content.Intent; import android.graphics.Bitmap; import android.media.Image; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; import org.json.JSONException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class ImageListView extends AppCompatActivity implements AdapterView.OnItemClickListener { private ListView listView; public static final String GET_IMAGE_URL="http://simplifiedcoding.16mb.com/PhotoUpload/getAllImages.php"; public GetAlImages getAlImages; public static final String BITMAP_ID = "BITMAP_ID"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_list_view); listView = (ListView) findViewById(R.id.listView); listView.setOnItemClickListener(this); getURLs(); } private void getImages(){ class GetImages extends AsyncTask<Void,Void,Void>{ ProgressDialog loading; @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(ImageListView.this,"Downloading images...","Please wait...",false,false); } @Override protected void onPostExecute(Void v) { super.onPostExecute(v); loading.dismiss(); //Toast.makeText(ImageListView.this,"Success",Toast.LENGTH_LONG).show(); CustomList customList = new CustomList(ImageListView.this,GetAlImages.imageURLs,GetAlImages.bitmaps); listView.setAdapter(customList); } @Override protected Void doInBackground(Void... voids) { try { getAlImages.getAllImages(); } catch (JSONException e) { e.printStackTrace(); } return null; } } GetImages getImages = new GetImages(); getImages.execute(); } private void getURLs() { class GetURLs extends AsyncTask<String,Void,String>{ ProgressDialog loading; @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(ImageListView.this,"Loading...","Please Wait...",true,true); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); loading.dismiss(); getAlImages = new GetAlImages(s); getImages(); } @Override protected String doInBackground(String... strings) { BufferedReader bufferedReader = null; try { URL url = new URL(strings[0]); HttpURLConnection con = (HttpURLConnection) url.openConnection(); StringBuilder sb = new StringBuilder(); bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream())); String json; while((json = bufferedReader.readLine())!= null){ sb.append(json+"\n"); } return sb.toString().trim(); }catch(Exception e){ return null; } } } GetURLs gu = new GetURLs(); gu.execute(GET_IMAGE_URL); } @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent = new Intent(this, ViewFullImage.class); intent.putExtra(BITMAP_ID,i); startActivity(intent); } } |
- 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.

- The xml code for the above layout is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context="net.simplifiedcoding.imageuploadsample.ViewFullImage"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/imageViewFull" /> </RelativeLayout> |
- Inside your java class for this layout write the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | package net.simplifiedcoding.imageuploadsample; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; public class ViewFullImage extends AppCompatActivity { private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_full_image); Intent intent = getIntent(); int i = intent.getIntExtra(ImageListView.BITMAP_ID,0); imageView = (ImageView) findViewById(R.id.imageViewFull); imageView.setImageBitmap(GetAlImages.bitmaps[i]); } } |
- 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.

Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.
Thank You!!
You are great !! This tutorial helped me alot and was much needed
Your welcome.. keep visiting and tell if some tutorial you want to be published here?
What to do incase if one wants to upload image and text in same table and at some point wants to send only data and not the image. Why does the app crash if no image is selected and upload button is pressed? how to overcome this?
add an edittext and add the string to the post request and send some empty values if no image is selected
if fetch images video file description in one page that time what code fill u……..
hey bilal hi!!
can you provide tutorial about “creating a remote control desktop” android app??
Thanks in Advance!!
where is the getImage php file?
Hi, I m following ur Android Upload Image Using PHP MySQL Tutorial buet i cant upload images on server i hv set path but images not uploaded on server side folder plz can u tell me where i wrong , i following same its ur code.
rply plz
hey i have a error when you press View image and what purpose of getImage.php and dir imageUpload
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 ?
And how to upload image and two strings ?
It will also upload large images…
and you can send your string with your image
I can upload large image when I change in line “bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);” 100 to 50. Can You tell me, what I should change in code to upload text with image ?
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.
Ok just wait and I will post a new tutorial for you 🙂
Thank you. I’ll be waiting
Please write tutorial for upload image with two strings ok?
Thanks a lot
Good job bro,
canyou show this tutorial using volley pls…
Yeah sure I will try to post a tutorial for that soon
Hi, i m refer your code for upload images on server and save database but i m i can’t upload images on server i m following whole steps but i cant do please tell me where i m wrong and give me solution asap.
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.
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….
Stay tuned and I will post a tutorial to upload larger files as well..
Hi Belal, Any updates on my question?
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.
Can’t understand what you are saying..
hello Belal Khan when I click on the “View Image” button closes the application help me please.
check the logcat for exact error
Great tutorial Belal, and I got same problem with Sidi.
On logchat, i got error in CustomList.java line: image.setImageBitmap(Bitmap.createScaledBitmap(bitmaps[position],100,50,false));
Need some help from you Belal. Thank you
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
You are getting a null pointer exception.. Tell me photos are getting uploaded on your app or not?
excuse me I do not understand English well.
yes the photos are uploaded from the server mysql
help me please
connect with me at faebook.com/probelalkhan I will try to sort out your problem
What causes a null pointer exceptions. The chosen image displays properly on the image view but the image is not uploaded, neither is the database updated. Please help me
in upload.php file replace “localhost” by “10.0.2.2” in $actualpath variable… because android device sometimes doesn’t get connection using localhost… in my case i replaced it… code working to good…
Hai, I need you php code, please attach it with your download url….
Get the scripts from here
https://drive.google.com/file/d/0B13EE_qsNQLpc0Y2Y1RRX0tWNDg/view?usp=sharing
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 ??
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..
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.
If your images are really large like in MBs then it cause problem. I will post a tutorial to upload larger files..
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!
bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
change to
bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);
Excuse me! I am very new to these. I want to ask what is the “server’s directory” mean? And how can I create one?
Here I meant to say that the project folder inside your server where you have stored your server side scripts
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
Hello, if you have fixed this error, please share it here. I also facing this problem. Thank you very much.
Can you plz post the code of sql query and explain what url should be used in upload.php path url
What do you mean by SQL query?? Create a normal table u can use the GUI interface of phpMyAdmin to create table
what url should be used in upload.php? and in some tutorial you didnt put getImage.php code also
Am using getAllImages.PHP in this tutorial i fetched all the images at once in a bitmap array
You put your own url where u want to store the images
i dont know what url should be placed can you please be more specific and explain me plz
Connect with me on facebook.com/probelalkhan
sent u a request 🙂
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/
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 ?
Have you tried downloading my project?
Thanks for reply.
Yea, I tried. It’s work ! But I change to my server, it’s not work.
I have followed the php code that you provided and create a sql table like yours.
I cant figure out where is the problem.
Hi Belal Khan.. can you do a tutorial for upload video into MySQL?
import android.support.v7.app.AppCompatActivity; is a problem in android studio
you should update your SDK
This is so helpful!! thanks i tried it and it works fine. i got a request, how to make the image in list view rounded??
Belal,
if I want to write php code using prepared statement, then How can I change in code?
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… 🙂
me 2 i need to do it in my project
how do i resolved the import android.support.v7.app.AppCompatActivity. I am trying many tutorial but can’t add this library.
update ur sdk
Thanks
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!
Please update the tutorial to use gridview to display all images
Great Job Brother. Can you please upload a app for Shopping cart.
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?
how do i display image along with text from mysql. please give me a suggestion,or tutorial.
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.
how to get pic along with text
data on login and show it in listview
.please post a tutorial.
Hii Belal Khan
i have one problem this tutorial example pls solve it.
image can not view
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?
Check your bitmaps array is properly got all the bitmaps or not.. may be this is null thats why you are getting an exception
do u got the solution for this?? same error??
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 =)
i want upload a image by clicking an camera option on flight ………………….. how to do??
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.
Can you help me with this I am getting Warning mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
How do i upload image to server and display image in app with one button?
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??
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.
hi my app show upload sccucessful. but i cant have anything in my database .
in logcat the error is sendUserActionEvent()=null
pls help
i try your code is good sucess
just button viewImage
download of server
force stop this program please help me
thanks about allthing
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
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??
Check this out
https://www.simplifiedcoding.net/android-feed-example-using-php-mysql-volley/
thank you i tested the code on this project .i can get the list with the names but i can’t get the pictures …know that the picture are uploaded in the file uploads…how cani get the pictures and display them on android activity ?
$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”;
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
i am getting error in upload.php when i run it from browser!!!!!
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”}]}
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
I want to store some description with image to server. but it shows as error. how can i upload text and image to server.
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)
Blank toast appear in when click on upload.. nothing happen in database..
Did you fix the blank toast bro?
belal give me local server coding
your code is very helpfull for me brother,
i always see your posts,i am following you….thanks
hey ur code is not working….coming some error plz give me correct code….
Please upload the example for the same using the retrofit library.
Thanks in advance.
belal, I was tested in api 17, but force close when I choose my picture, and I see my image in listview. why ?
This is not a good way.. I have written an another post follow this one to fetch images from server
https://www.simplifiedcoding.net/android-custom-listview-with-images-using-recyclerview-and-volley/
Hello Sir,
I use your code but images are not fetches from my database to folder. So it gives error. Please help me.
In this post I am downloading all the images at once.. this is not a good way when you are having a lots of images. or images size are greater.. You should use volley or picasso library to fetch images
check this post of fetching images from server I am using volley library here
https://www.simplifiedcoding.net/android-custom-listview-with-images-using-recyclerview-and-volley/
what if display images and text in listview? thank you
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
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
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
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.
I am facing the same problem. The path is stored in the table but image is not stored in uploads directory.
Please help.
heyy 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???
i hope u know
i have same probleme , did you found solution plz????
Sir i have one more attributes as Name of image i want show name and image in listview
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.
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
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
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……………..
Bilal i have followed your tutorial on google map….
How to draw path while device moving… its urgent please help me….
Thank you..
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???
give ur system ip address and rest of things what u have mentioned
Image path is getting saved to database, but image is not getting saved to folder.
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
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
Amazing tutorial man, just loved it………!! Thanks a ton………!!
Cheers 🙂 😀
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
try using volley with same php code
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 …
try using volley with same php
on Click Upload image showing a blank Toast.
please help me
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.
am getting an error when i run the upload.php file…which path should i use?yours or mine…$actualpath = “http://localhost/photoupload/$path”;
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.
this code is working properly but save image in folder is corrupt plz help me
if any CAPTCHA Code tutorial in android send me
hi sir.. I am getting my image in uploads but it is in 0bytes.. what to dp?? plzz help me
mail me ur exact problem on patilshashi43@gmail.com
I get a warning error put the file contents and writes are added to the database as 0
Belal Can you make a tutorial about the offline video mode like they used in youtube. Appreciate your help 🙂
Great and more great and a lot great 😉
helped me alot.
thanks alot.
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……………..
hello, please can you upload code php for downloading
code working properly for uploading but its showing zero size of images at server side help me
hi sir.. how to change text url with my title in database? I want to show my image and my title..thanks before
Reupload please..
I can’t download
https://dl.dropboxusercontent.com/s/697f4y7ah9x0wm0/android-upload-image-to-server-using-php-mysql.zip?dl=0
Error (429)
This account’s links are generating too much traffic and have been temporarily disabled!
Thank You
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.
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.
please send me link for upload image php mysql and disply images in listview .please sir send me proper link for download this code
Mail me ur mail @ patilshashi43@gmail.com
how can i display images from server to listview that data is stored as a BLOB
Please can You help me with this.
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
Capture image from phone and upload
Capture image from phone and upload code please
I am not able to download this code.Please review it
My mail id is gauravyadav333@gmail.com
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
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
Hello! Thanks for the tutorial.
Greetings from Mexico.
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…………..!
Works perfectly. Such a good work
i cant download your source code. please send me by email.thank you
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! 🙂
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
In my case it work in Emulator but not in real device …. im using samsung j1 any help??
Make sure your host is accessible by your real device
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
Where can i found getimage.php ?
Can u please provide code for directly capturing picture from android application and storing in database???
Please reply at earliest
Hello! I am implementing your code but i could not upload neither image nor its path on the server. Please help.
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
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
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
Showing error on php code. Unable to upload image.. Pls help!!!
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.
Check this course to learn about mysql and android:
https://www.youtube.com/playlist?list=PLk7v1Z2rk4hhGfJw-IQCm6kjywmuJX4Rh