Jump to content

How to print upper folder PHP


inversesoft123

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.