SirChick Posted June 28, 2008 Share Posted June 28, 2008 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 More sharing options...
Guest Posted June 28, 2008 Share Posted June 28, 2008 http://uk3.php.net/file_exists Link to comment https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/#findComment-576721 Share on other sites More sharing options...
SirChick Posted June 28, 2008 Author Share Posted June 28, 2008 \o/ Thankyou! I shall take a read on this! Link to comment https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/#findComment-576723 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 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. Link to comment https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/#findComment-576724 Share on other sites More sharing options...
SirChick Posted June 28, 2008 Author Share Posted June 28, 2008 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. Link to comment https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/#findComment-576728 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 I just did a search for 'PHP image exists' and it came up as the top result. http://www.google.co.uk/search?client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&channel=s&hl=en&q=php+image+exists&meta=&btnG=Google+Search Link to comment https://forums.phpfreaks.com/topic/112336-solved-php-image-checking/#findComment-576736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.