Prevent Parent Directory in php directory listing program
Posted: Tue Aug 30, 2011 2:33 pm
I created a script to show all folders and files.
There is a variable called
$rootdir = "/path/to/root/directory";
$rootdir is the lowest directory the software should list folder contents.
However, if you did http://example.com/?dir=/../ it would show /path/to/root
How can I write a check that prevents anyone from going past $rootdir?
Thanks!
There is a variable called
$rootdir = "/path/to/root/directory";
$rootdir is the lowest directory the software should list folder contents.
However, if you did http://example.com/?dir=/../ it would show /path/to/root
How can I write a check that prevents anyone from going past $rootdir?
Thanks!