Jump to content

[SOLVED] Php image checking


SirChick

Recommended Posts

I have a database that stores the location of images in my server.

 

What i want to know how ever, is if the image cannot be found in the folder, can php check this and then change its image to a default image for when ever the image it is suppose to look for cannot be found?

 

I have this:

 

<img src="<?=$ImageLocation?>" alt="" height="100px" width="100px">

So say it was looking for /images/1.gif

 

But it doesn't find 1.gif in the folder /images..is there a way in php, to change the variable that contains 1.gif to default.gif so that it then loads:

 

/images/default.gif

 

I'm hoping theres a function for this ?

 

hope you can help.

 

 

Link to comment
https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/
Share on other sites

if (!file_exists($ImageLocation))
{
   $ImageLocation = "defaultImage.jpg";
}

 

You could have easily solved this problem by typing a few relevant keywords along with the word 'PHP' into Google... you might also have learned something as well.

 

If you must know I did but didn't find this function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.