Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Hinrich Specht
November 7, 2004, 3:02 pm
rate this thread
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";
$item_detail_image = $image;
$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?
Thanks in advance,
Re: Problem with file_exists
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