|
Posted by Colin McKinnon on 06/18/06 21:26
Jan Thomä wrote:
> On Sun, 18 Jun 2006 10:24:20 GMT Jerry M. Gartner wrote:
>> [...] For example: I have x.php and it contains <img
>> src="images...">, (amongst other things, like php code), which resolves
>> the
>> correct image path when opened under / but when x.php is read into a
>> file
>> under /dir the image no longer resolves, for obvious reasons. With
>> absolute paths, this isn't an issue but it is with relative paths.
>
> Well to be on the safe side use absolute paths, this will definitely work.
> To keep your scripts maintainable, make a configuration file where you
> will put the paths in. E.g
>
<snip>
I would second this approach - in larger applications this has often been
one of the first 'include' files I've implemented, usually declaring the
path both in terms of its URL and the filesystem namespace:
// note - be consistent about trailing dir seperator
$image_url_prefix="http://my.server.com/~colin/project/images/";
$image_file_prefix="/home/colin/public_html/project/images/";
....
Of course, you'll then realise that the included file itself has a relative
and absolute path....but the advantage of this approach is that you can use
the path relative to one of the directories declared in the include_path
config file setting which removes the problem.
C.
Navigation:
[Reply to this message]
|