I have a path to a folder (e.g. /var/www/tester/assets/themes/default/css/).
a user can provide a relative path to the folder, so for example. layout/ie7.css would give the path of /var/www/tester/assets/themes/default/css/layout/ie7.css.
This works fine, however I want the users to be able to navigate up the directory tree as well.
so with the path to the css folder again if a user provides ../../cache/css/ie7.css I want the path to end up as /var/www/tester/assets/themes/default/cache/css/ie7.css.
I thought I could just pass them together to realpath() e.g:
$base = '/var/www/tester/assets/themes/default/css/';
$user_path = '../../cache/css/ie7.css';
$final_path = realpath($base.$user_path);
But that just returns false. How can I do this?
first of all the real path function also checks whether the given path exists… Are you sure your path exists???
would not end up in
as you suggest but it ends up in
Does this folder with the given file exist?