For an assignment we have to create a shopping cart. For some reason, this happens:
Here's the code:
The result of this is strange. It prints that "something went wrong", then it removes the file any way? What's going on here? I have tried the same code with and without dirname(__FILE__), same result. I don't understand how it an IF can be TRUE and FALSE. Is it one of those things where you need like === or !== or something?PHP Code:$file_path=dirname(__FILE__) . "../images/products/" . $_GET['picpath']; // It's just the file name here, such as foo.gif, or bar.jpg
if (!is_file($file_path))
{
printf("Something went wrong (The file doesn't exist or is not writable: <b>" . $file_path . "</b>). Please remove it manually.");
}
if (is_file($file_path)) //file_exists() also works.
{
unlink($file_path);
}
You can be sure that this is the only code that has anything to do with testing for files etc.




Reply With Quote