Reputation: 61
I have the following code:
if(file_exists("../media/books/$oldcover")) {
unlink("../media/books/$oldcover");
} else {
//do nothing
}
Why does the if works good and the else returns this annoying note: Unlink(../media/books/) [function.unlink]: Is a directory in (path...)
I want the else doing nothing.
Upvotes: 0
Views: 40
Reputation: 28721
Sounds like your $oldcover
variable could be empty and thus is checking if the directory exists or not.
This then tries to unlink
the directory instead. Perhaps you should try this:
if($oldcover && file_exists("../media/books/$oldcover")) {
unlink("../media/books/$oldcover");
} else {
//do nothing
}
Upvotes: 1
Reputation: 3321
It appears your variable $oldcover
is empty. You could also change the conditional to check if the file exists and that it is not a directory.
if(file_exists("../media/books/$oldcover") && !is_dir("../media/books/$oldcover"))
Upvotes: 1