display image in a different location in file system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johnhelen
Forum Commoner
Posts: 45
Joined: Mon Feb 19, 2007 9:17 pm

display image in a different location in file system

Post 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
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

You could reference the image file with a complete path i.e. http://www.../files/images/logo.gif
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

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