I’ve got this weird problem where PHP can see most of the files in a directory, but not all of them. They all have the same owner, group, and permissions. I’m using PHP’s scandir to get a list of files in a directory, and have also tried readdir and glob with the same results.
Doing a specific test with file_exists on one of the files that PHP lists using scandir and one it misses, I’ve found that when I use a relative path it can’t see the missing file. However if I use an absolute path then it can see both of the files.
But using scandir or glob, even with an absolute path it still can’t see all the files (no difference from using a relative path).
The setup is this - I have a directory with the PHP files in. Within this directory is an ‘Img’ directory, which is a symlink to a directory on block storage. The PHP script then uses scandir to get a list of files within a sub-dir of the ‘Img’ dir.
Anyone got any ideas?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!