This is a discussion on How to acces the same dir from different dirs.. within the PHP Language forums, part of the PHP Programming Forums category; Hi - I cant fins the right way to put this problem.. I have a structore wich is like this.. www....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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" <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> skrev i en meddelelse news:4016573a$0$323$e4fe514c@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 |
|
|||
|
"Timo J" <Timo*Remove*@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 |
|
|||
|
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. :P Regards, Erwin Moller |
|
|||
|
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; |
|
|||
|
"Krešo Kunjas" <deresh@gamebox.net> skrev i en meddelelse news:sggcp1o1uqc.1fkd3gbsnmwxv.dlg@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. |