phillystyle123
asked on
re: php relative paths to files using includes
i have 2 files:
index.php
and
subdirectory/index.php
both are using the same include file with relative links to say images/image.gif
can i set up some sort of configuration file in my root directory that somehow defines the a path so i don't have to make "images/image.gif" absolute in (i.e. - "http://www.mysite.com/images/image.gif"??
if so please explain thoroughly - i've never done this be for (please be gentle LOL)
index.php
and
subdirectory/index.php
both are using the same include file with relative links to say images/image.gif
can i set up some sort of configuration file in my root directory that somehow defines the a path so i don't have to make "images/image.gif" absolute in (i.e. - "http://www.mysite.com/images/image.gif"??
if so please explain thoroughly - i've never done this be for (please be gentle LOL)
ASKER
hmm - i have it set up but it doesn't make sense to me - am i supposed to add that variable to each file path:
like $image_dir/bla.gif ?
i've got this in my config file:
<?php
$image_dir = "usr/home/healthpresence/o rthoneuro/ images/";
?>
and then this at the top of both index.php files:
<?php include('includes/config.p hp');?> and <?php include(../'includes/confi g.php');?> but it's not working yet
like $image_dir/bla.gif ?
i've got this in my config file:
<?php
$image_dir = "usr/home/healthpresence/o
?>
and then this at the top of both index.php files:
<?php include('includes/config.p
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that's funny - i'd actually already done this in a slightly different way - thanks tons - much apprecated
that's not hard to do.
Create a file config.php, and define the path to the image directory there, like:
<?php
$image_dir = "[absolute_path]/images/";
?>
Put in the absolute path instead of [absolute_path].
Then just include the config file in both index.php files:
In /index.php:
<?php
include 'config.php';
...
?>
In /subdirectory/index.php:
<?php
include '../config.php';
...
?>
Best regards,
sd