How to include file outside document root?
Posted
by Brayn
on Stack Overflow
See other posts from Stack Overflow
or by Brayn
Published on 2010-03-03T09:37:28Z
Indexed on
2010/03/08
10:21 UTC
Read the original article
Hit count: 371
Hey,
What I want do to is to include 'file1.php' from 'domain1' into 'file2.php' on 'domain2'. So what I figured I should do is something like this:
file2.php
require_once '/var/www/vhosts/domain1/httpdocs/file1.php';
But this won't work for reasons I can't truly grasp. So what I did was to add my path to the include path. Something like:
file2.php
set_include_path(get_include_path() . PATH_SEPARATOR . "/var/www/vhosts/domain1/httpdocs");
require_once 'file1.php';
So can you please give me some hints as of where I'm doing wrong ?
Thanks
UPDATE - Either way I get the following error message:
Fatal error: require() [function.require]: Failed opening required '/var/www/vhosts/domain1/httpdocs/file1.php' (include_path='.:/php/includes:/usr/share/pear/') in /var/www/vhosts/domain2/httpdocs/file2.php on line 4
Also I have tried this both with safe_mode On and Off.
UPDATE2: Also I've changed the permissions to 777 on my test file and I've double-checked the paths to the include file in bash.
© Stack Overflow or respective owner