How to acces the same dir from different dirs.. – PHP

  php

Q(Question):

Hi – I cant fins the right way to put this problem..

I have a structore wich is like this..

www.thewebsite.dk/images/

And from a dir

http://www.thewebsite.dk/something/s…gelse/test.php
and
www.thewebsite.dk/something/test.php

i like to include the same image pic.jpg, with the same code but i cant get
it to work..

I have tried.. include("/images/pic.jpg"); and the below but none work..

/images/pic.jpg
images/pic.jpg
//images/pic.jpg
\images\pic.jpg
images\pic.jpg
\\images\pic.jpg

What am i doing wrong..

Best regards

Timo.

A(Answer):

Timo J wrote:

Hi – I cant fins the right way to put this problem..

I have a structore wich is like this..

www.thewebsite.dk/images/

And from a dir

http://www.thewebsite.dk/something/s…gelse/test.php
try:

include ‘../../images/pic.jpg’;

from here.
…/ means ‘up one directory’
and
www.thewebsite.dk/something/test.php
try:

include ‘../images/pic.jpg’;

i like to include the same image pic.jpg, with the same code but i cant
get it to work..

I have tried.. include("/images/pic.jpg"); and the below but none work..

/images/pic.jpg
images/pic.jpg
//images/pic.jpg
\images\pic.jpg
images\pic.jpg
\\images\pic.jpg

What am i doing wrong..

Best regards

Timo.

Regards,
Erwin Moller

A(Answer):

Yep thats will do the trick – but i where hoping that there where some
syntax so that i where able of useing the same code manny places without
changing it..

But thanks anyway

Timo

"Erwin Moller"
<si******************************************@spam yourself.com> skrev i en
meddelelse news:40*********************@news.xs4all.nl…

Timo J wrote:

Hi – I cant fins the right way to put this problem..

I have a structore wich is like this..

www.thewebsite.dk/images/

And from a dir

http://www.thewebsite.dk/something/s…gelse/test.php

try:

include ‘../../images/pic.jpg’;

from here.
../ means ‘up one directory’

and
www.thewebsite.dk/something/test.php

try:

include ‘../images/pic.jpg’;

i like to include the same image pic.jpg, with the same code but i cant
get it to work..

I have tried.. include("/images/pic.jpg"); and the below but none work..

/images/pic.jpg
images/pic.jpg
//images/pic.jpg
\images\pic.jpg
images\pic.jpg
\\images\pic.jpg

What am i doing wrong..

Best regards

Timo.

Regards,
Erwin Moller

A(Answer):

"Timo J" <Ti**********@s-d-i.dk> wrote:

I have a structore wich is like this..

www.thewebsite.dk/images/

And from a dir

http://www.thewebsite.dk/something/s…gelse/test.php
and
www.thewebsite.dk/something/test.php

i like to include the same image pic.jpg, with the same code but i
cant get it to work..

I have tried.. include("/images/pic.jpg"); and the below but none
work..

Hi Timo,

include() doesn’t expect a URL (unless prepended by http/ftp. etc.) but a
system path. So use the full system path, e.g.:

include("/www/docroot/images/pic.jpg");

HTH;
JOn

A(Answer):

Timo J wrote:

Yep thats will do the trick – but i where hoping that there where some
syntax so that i where able of useing the same code manny places without
changing it..

In that situation a complete URI will do the trick.

use:

<img src="http://www.thewebsite.dk/images/pic.jpg">

which will always point to the right location.
Because imageloading is done by the browser, I expect it to be as fast as
…/../etc. notation.
Except when your browser does a namelookup every time, which I hope it
doesn’t. 😛

Regards,
Erwin Moller

A(Answer):

On Tue, 27 Jan 2004 13:24:36 +0100, Timo J wrote:

Yep thats will do the trick – but i where hoping that there where some
syntax so that i where able of useing the same code manny places without
changing it..

But thanks anyway

try using server constant DOCUMENT_ROOT if relative addressing doesnt work
for you

example

$homedir = $_SERVER["DOCUMENT_ROOT"].$mydir;

A(Answer):

"Kre¹o Kunjas" <de****@gamebox.net> skrev i en meddelelse
news:sg***************************@40tude.net…

On Tue, 27 Jan 2004 13:24:36 +0100, Timo J wrote:

Yep thats will do the trick – but i where hoping that there where some
syntax so that i where able of useing the same code manny places without
changing it..

But thanks anyway

try using server constant DOCUMENT_ROOT if relative addressing doesnt work
for you

example

$homedir = $_SERVER["DOCUMENT_ROOT"].$mydir;

Perfect…. just the rigth stuff!

Thanks All !

Timo.

LEAVE A COMMENT