I have a main directory on a server with a sub-directory called upload, in which I have a collection of pictures. I want to show all the picture names in the upload directory. I’m using the following code:
foreach(glob("".DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."*.{jpg,gif,png}", GLOB_BRACE) as $filename)
{
echo $filename.'<br/>';
}
And there is no result (white screen). However, when using it for the current directory or the upper (with ../) it works correctly. I made sure it is not a permissions problem and that there are files in the upload directory but still the problem persists. Can somebody help me out of it? Thanks in advance!
Remove the first DIRECTORY_SEPARATOR from the pattern. This is assuming that you are in the main directory.