1

How do I access a folder outside my subdomain folder.

For example, my domain is localhost and I have a subdomain m.localhost. And their folders are:

Server Root:
    /cdn/
    /contents/
    /mobile/
    .htaccess

And the folder /mobile/ is the root directory of my m.localhost. From the m.localhost, how do I access the /contents/ directory and it's contents using PHP?

$_SERVER['DOCUMENT_ROOT'] only selects the subdomain directory root.

KevinT.
  • 272
  • 6
  • 16

1 Answers1

2

Try this.

realpath(dirname(__FILE__).'/../../../contents/nav/quicklinks.txt');
Jay Bhatt
  • 5,601
  • 5
  • 40
  • 62
  • Well, I was trying to get a file's content on the `/contents/` folder and store it as a variable. I wanted to achieve: `$quicklinks = file_get_contents(realpath(dirname(__FILE__).'/../contents/nav/quicklinks.txt'));` but I got this error: `Warning: file_get_contents(): Filename cannot be empty in C:\XAMPP\htdocs\mobile\cdn\php\nav.php on line 5`. How to fix? – KevinT. Apr 28 '14 at 08:41
  • @KevinHandogTresuelo Since your calling the script from a sub directory of mobile folder its not working. I have updated my answer. – Jay Bhatt Apr 28 '14 at 08:44
  • @KevinHandogTresuelo Your welcome. Don't forget to +1 if it was helpful. – Jay Bhatt Apr 28 '14 at 08:48
  • is there a way that the `/../../../contents/nav/quicklinks.txt` be an absolute url? Like it would be just `/contents/nav/quicklinks.txt`? – KevinT. Apr 29 '14 at 01:47