How can I set an absolute path for include function in php above the working directory?
        Posted  
        
            by Baros
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Baros
        
        
        
        Published on 2010-04-10T13:29:38Z
        Indexed on 
            2010/04/10
            13:33 UTC
        
        
        Read the original article
        Hit count: 355
        
I am running a script from
/wp-content/themes/currenttheme/chat.php
I want to include in the above php another one located in
/forum/chat/index.php
The index.php includes its own files
I already tried
`$root = $_SERVER['DOCUMENT_ROOT'];
include($root."/forum/chat/index.php");`
but I get this error
`Warning: require(D:/My Dropbox/xampp/htdocs/lib/custom.php) [function.require]: failed to open stream: No such file or directory in D:\My Dropbox\xampp\htdocs\forum\chat\index.php on line 17
Fatal error: require() [function.require]: Failed opening required 'D:/My Dropbox/xampp/htdocs/lib/custom.php' (include_path='.;\My Dropbox\xampp\php\PEAR') in D:\My Dropbox\xampp\htdocs\forum\chat\index.php on line 17`
(the index.php also includes some files, but the /forum is ommited somehow in the path)
then I tried
`$path = getcwd();
$myfile = "/forum/chat/index.php";
include ($path.$myfile);`
and got this error:
`Warning: include(D:\My Dropbox\xampp\htdocs\forum/forum/chat/index.php) [function.include]: failed to open stream: No such file or directory in D:\My Dropbox\xampp\htdocs\wp-content\themes\currenttheme\chat.php on line 24
Warning: include() [function.include]: Failed opening 'D:\My Dropbox\xampp\htdocs\forum/forum/chat/index.php' for inclusion (include_path='.;\My Dropbox\xampp\php\PEAR') in D:\My Dropbox\xampp\htdocs\wp-content\themes\currenttheme\chat.php on line 24`
© Stack Overflow or respective owner