Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Global File access outside web directory.

In my server I have all the web directories for my websites in /web.
So /web/SITENAME/html/ Folders and files for that particular website.

Inside the HTML folder for each individual directory how do I link to a folder outside of that folder?

So let's say I have my index.php which is inside of sitename/html/ and inside the index file I want to link to another .php file that's outside of this directory. How would I go about doing that?
Normally in php you can simply do
PHP Code

<?php 
include 'filename' ; 
but that file is inside your current web directory. I need to link a file that's outside of this directory.

Hope i explained that well enough tried giving multiple examples.  

Thanks.

~ Dale
You would include an upper directory by doing:
PHP Code

<?php 
include("../file_in_one_directory_up.php"); 

The ".." signify one directory up, so here's how to do something that's two up:
PHP Code

<?php 
include("../../file_two_directories_up.php"); 

And so on.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(May 15, 2018 04:26 PM)Nachfolger Wrote:  You would include an upper directory by doing:
PHP Code

<?php 
include("../file_in_one_directory_up.php"); 

The ".." signify one directory up.

How would I go two directories up?

Setup:
Sitename/html/ current web directory.

So actually I'd need to go three levels up.
(May 15, 2018 04:26 PM)Dale Carnegie Wrote:  How would I go two directories up?
Re-read my post. I was editing it as you quoted me.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
Thanks so much. Just saw your edit!
It only works as long as open_basedir is not in effect or the directory you want to reach is on the list of open_basedir directories.
PS: if a shared hosting does not have open_basedir set up it's better to avoid it.
You see, Doctor, God didn't kill that little girl. Fate didn't butcher her and destiny didn't feed her to those dogs.
If God saw what any of us did that night he didn't seem to mind. From then on I knew... God doesn't make the world this way.
We do.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by BabadookApr 23, 2019 07:50 AM 3 189 Apr 23, 2019 07:50 AM
Last Post: .trigious
[PHP] by BabadookFeb 1, 2019 10:50 PM 11 371 Feb 1, 2019 10:50 PM
Last Post: Babadook
[PHP] by Viper228Aug 26, 2018 02:28 PM 0 123 Aug 26, 2018 02:28 PM
Last Post: Viper228