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 Link to comment https://forums.phpfreaks.com/topic/147423-how-to-print-upper-folder-php/ 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/>'; Link to comment https://forums.phpfreaks.com/topic/147423-how-to-print-upper-folder-php/#findComment-773906 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. Link to comment https://forums.phpfreaks.com/topic/147423-how-to-print-upper-folder-php/#findComment-773916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.