Very odd problem with PHP not seeing files

August 18, 2018 801 views
PHP Ubuntu

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?

Be the first one to answer this question.