Page 1 of 1

display image in a different location in file system

Posted: Mon Jul 30, 2007 1:29 am
by johnhelen
Hello

I have an index page in my local computer as the following:

http://local.myweb.nz/index.php

This web has DocumentRoot as:

/home/myname/workspace/myweb/html

The index.php is inside html folder

In this index.php, I want to have an image logo called "logo.gif". The problem here is, this image is in totally different folder in the file systems

/home/myname/workspace/files/images/logo.gif

I tried this in the file "index.php"

<img src="/home/myname/workspace/files/images/logo.gif" />

But I cannot see the image ...

How I can fix this problem or it is impossible ...


Many thanks
johnhelen

Posted: Mon Jul 30, 2007 1:38 am
by jmut
Well images,css and all client side stuff should be visible through web root.
In your case simplest I think will be creating symlink within webroot that points to other dir. And allowing apache to follow symlink.

Posted: Mon Jul 30, 2007 4:21 am
by aceconcepts
You could reference the image file with a complete path i.e. http://www.../files/images/logo.gif

Posted: Mon Jul 30, 2007 4:27 am
by miro_igov
jmut wrote:Well images,css and all client side stuff should be visible through web root.
In your case simplest I think will be creating symlink within webroot that points to other dir. And allowing apache to follow symlink.
It is not true, my compatriot. Displaying files out of the web root could be done by reading the image file with some of the file functions, setting appropriate headers depending on the image type and printing the content of the file. This must be done in separate php file which will be used as SRC attribute of the IMG tag.

Posted: Mon Jul 30, 2007 4:53 am
by jmut
miro_igov wrote:
jmut wrote:Well images,css and all client side stuff should be visible through web root.
In your case simplest I think will be creating symlink within webroot that points to other dir. And allowing apache to follow symlink.
It is not true, my compatriot. Displaying files out of the web root could be done by reading the image file with some of the file functions, setting appropriate headers depending on the image type and printing the content of the file. This must be done in separate php file which will be used as SRC attribute of the IMG tag.
Yes it is true, my compatriot or whatever this is :)
Although using script as you suggest is more flexible and could add more functionality. Symlink works and is simple.

Posted: Mon Jul 30, 2007 5:30 am
by miro_igov
I meant
Well images,css and all client side stuff should be visible through web root.
is not true.

Lack of English :arrow: http://dictionary.reference.com/browse/compatriot

Posted: Mon Jul 30, 2007 8:01 am
by superdezign
miro_igov wrote:It is not true, my compatriot. Displaying files out of the web root could be done by reading the image file with some of the file functions, setting appropriate headers depending on the image type and printing the content of the file. This must be done in separate php file which will be used as SRC attribute of the IMG tag.
Which would be both wasteful and impractical. It definitely would work against hotlinking though.