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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $100 of credit to try our products over 60 days!