inversesoft123 Posted March 1, 2009 Share Posted March 1, 2009 Hello can anyone tell me how to print upper folder in PHP from the file which is located in sub folder.. eg: public_html / mysite / music / new / index.php $home = 'http://mysite.com/'; $current_folder = basename(dirname(__FILE__)); echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'; In this code I can link to currennt folder 'new' but how do I link 'music' folder in this script.. Pls Help... Tnx n advance Quote Link to comment Share on other sites More sharing options...
bothwell Posted March 1, 2009 Share Posted March 1, 2009 You've already got your root directory set as $home, so just build it from there. echo '<a href="'.$home.'">Home</a> / <a href="'.$home'music">Music</a><br/>'; Quote Link to comment Share on other sites More sharing options...
a-scripts.com Posted March 1, 2009 Share Posted March 1, 2009 Well the music folder does not need to be exactly right under the home folder. Also note that server path and web path might be and most of the times are different. So using something like dirname(__FILE__) is not the best idea when you want to use it as an URL. However linking to parent directory could be usually done via ".." . So when the current directory is /home/test/new and I want to link to a file inside that "test" I can write /home/test/new/../file.php. This works for both server path and web path. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.