开发者

Is it possible to use relative paths with PHP scandir and does authentication affect scandir?

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜