Forum Moderators: coopster

Message Too Old, No Replies

Cannot use relative path

Relative path in pHp

         

chuender

5:37 am on May 1, 2004 (gmt 0)

10+ Year Member



My code works when I use the absolute path - "C:\apache2\htdocs" but I cannot use the relative path. Is there something I need to do in php.ini or httpd.conf to fix this?

I am having trouble when I upload my code to Linux environment.

Thanks.

DanA

6:54 am on May 1, 2004 (gmt 0)

10+ Year Member



remove c: as linux doesn't use this code.
Windows will accept it.
Relative paths should also work in both OS.

ergophobe

5:18 pm on May 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm guess that you have includes and such in subdirectories, so you don't always know what the path will be relative to.

The best thing to do is to use things like

$x = 'http://' . $_SERVER['SERVER_NAME'] . '/relative/path/file.php';

$y = $_SERVER['DOCUMENT_ROOT'] . '/relative/path/file.php'

Watch out for those slashes.

Tom