Dusan Dimitrijevic Dusan Dimitrijevic - 6 months ago 27
PHP Question

Glide won't load some image URLs

I have created Restful Api, so the user can communicate with my server database. First what i'm uploading image that user choose from Gallery into the database, using function for converting bitmap to string:

public String getStringImage(Bitmap bmp){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos);
byte[] imageBytes = baos.toByteArray();
return Base64.encodeToString(imageBytes, Base64.DEFAULT);

After that i'm storing the image path in database and decoding encoded image using these code in PHP:

if (!is_null($image)) {
file_put_contents($pathToImage, base64_decode($image));

And the result of the image is this:


When i try to get this url from adapter, i'm getting nothing. This is the code i have used:

String imagePath = joke.getImagePath();

Uri uri = Uri.parse(imagePath);

if (Uri.EMPTY.equals(uri)) {
} else {

I know that something is wrong with the url because when i have tried loading some random url like this one:


It was working. So what could be wrong with my URL?


If someone is having the same problem like i do, just don't forget to put

http:// for the path of image which you are storing in database. That was the case for me:

I was doing like this and it is wrong:

if($image === 'null') {
    $actualpath = "null";
} else {
    $actualpath = "ashfoundation.net/$path";

This is how it supposed to look:

if($image === 'null') {
    $actualpath = "null";
} else {
    $actualpath = "http://ashfoundation.net/$path";