Pergunta

I have an authenticated directory in my site that has a bunch of directories of photos in it. If you log in you can access these photos.

/admin/galleries/

I want to build another page outside of that directory that I can grant guest access to viewing the list of directories in the authenticated directory.

/guest/access/

I just need a simple list of the directories in the /admin/galleries/ dir. I'm trying to use scandir.

$folderlist = scandir("../../admin/galleries");

This doesn't return false, but it returns empty. I'm not sure why? Is it the authentication on that directory that's blocking access via scandir? I wouldn't have thought that would have affected a server process like scandir.

Is the relative path a problem? When I make a dummy directory inside of /guest/access/ and change the scandir path to scandir("."), it outputs that directory's name. But if I move that same directory up into the /guest/ directory and change scandir to scandir("..") or scandir("../../guest"), it returns empty again. That makes me think it's not an authentication problem, but something with scandir itself?

Foi útil?

Solução 2

Sorry to have left this question unanswered so long:

It wasn't returning empty, I just hadn't incorporated the correct relative path into my echo statements and had run them through an is_dir() statement that returned false because those directories didn't exist in the local directory. Dumb mistake.

Outras dicas

Try to use dirname(__FILE__) before your /../../

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top