Hinrich Specht wrote:
I have a problem using file_exists. I want to use file_exists to
dertermine if a product-image is available or not to show either the
product-image or a standard-image.
This is the code:
$image = "../../artimages/".$item_code.".jpg";
if (file_exists($image))
$item_detail_image = $image;
else
$item_detail_image = $toshopdata."img/no_image.jpg";
The Problem: If I use "../../artimages/".$item_code.".jpg" as image
src, the image is displayed correctly...meaning the file does exist in
the given path.
The file_exists - method on the other hand always returns false, and I
don´t know why. Can anyone help?
Maybe the url path is different from the file path? Is the directory
"artimages" actually located in the grandparent directory of the directory from
which the script is being called? Usually that's the case, but it might be
different depending on how you're implementing your code above (like if the code
above sits in an admin directory and creates static HTML or something) or if
you're using a <BASE HREF=""> tag.
Maybe try replace file_exists with fopen to generate an error (make sure you
have errors turned on). It should tell you that the file won't open and give
you the absolute path to it. Take a look at that path and I'll bet you'll see
what's wrong...
Shawn
--
Shawn Wilson
sh***@glassgiant.com http://www.glassgiant.com