dirname(LOG_PATH)
returns the parent of the LOG_PATH
(E:\xampp\htdocs\photo
), so your if
statement is true when the photo
folder exists, not when the logs
folder exists.
You should modify the condition to be:
if (is_dir(LOG_PATH)) {
} else {
mkdir(LOG_PATH, 0777, true);
echo "Directory created. ". LOG_PATH ."<br />";
}
And, if you are leaving the first branch empty, just negate the condition:
if (!is_dir(LOG_PATH)) {
mkdir(LOG_PATH, 0777, true);
echo "Directory created. ". LOG_PATH ."<br />";
}
And by the way, the mkdir
call may fail if you don't have permissions to create a new folder there, so you should check if that fails or not:
if (!is_dir(LOG_PATH)) {
if (mkdir(LOG_PATH, 0777, true)) {
echo "Directory created. ". LOG_PATH ."<br />";
} else {
throw new Exception("Can't create folder " . LOG_PATH);
}
}