Reputation: 893
I have a problem with my opendir
function.
if ($handle = opendir($dir)) {
echo "Directory handle: $handle\n";
echo "Entries:\n";
while (false !== ($entry = readdir($handle))) {
echo "$entry\n";
}
closedir($handle);
}
I checked if my folder exists and it does. I chmodded the permissions to 777. What could be the problem?
For example: images/car/Volvo_S40_4dr_sedan/
Doesn't work. What is the problem?
Upvotes: 1
Views: 2025
Reputation: 1531
It seems that you are using relative paths. If so then make sure you correctly construct the path relative to your script's current working directory.
To troubleshoot assign an absolute path to $dir
, eg. $dir = "/var/www/myproject/images/car/Volvo_S40_4dr_sedan/"
. If it works then the cause of the problem is a bad reference of relative path.
I would recommend you to stick with absolute paths unless you have a good reason to use relative paths.
Upvotes: 2