How to acces the same dir from different dirs..

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....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-27-2004
Timo J
 
Posts: n/a
Default How to acces the same dir from different dirs..

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.


Reply With Quote
  #2 (permalink)  
Old 01-27-2004
Erwin Moller
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..

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
Reply With Quote
  #3 (permalink)  
Old 01-27-2004
Timo J
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..

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



Reply With Quote
  #4 (permalink)  
Old 01-27-2004
Jon Kraft
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..

"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
Reply With Quote
  #5 (permalink)  
Old 01-27-2004
Erwin Moller
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..

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


Reply With Quote
  #6 (permalink)  
Old 01-27-2004
Krešo Kunjas
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..

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;
Reply With Quote
  #7 (permalink)  
Old 01-27-2004
Timo J
 
Posts: n/a
Default Re: How to acces the same dir from different dirs..


"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.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0