Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
cynthie

Accessing Images Placed One Level Above The Root Folder

Recommended Posts

Clicking around the Internet seems to state that images can only be accessed via http, and that I can't use php's 'include()' function to do it.

.

1.    I'd appreciate any suggestions for effective ways to access the images when placed one or two levels above/behind the root folder.

.

2.    Are there good alternate ways to pull up the images when placed in the regular images folder in front of the root folder, other than using http which means referencing them relatively or absulutely?

.

Thanks.

 - Cynthie

Share this post


Link to post
Share on other sites

HI Cynthie,

 

 http ( Hypertext Transfer Protocol ) is the technology that delivers the html ( Hyper text markup language).

 

so, you would write the source for the image using the img tag in html, then use the php fuction include to include that html file.

 

do you have sound knowledge of html ?

Share this post


Link to post
Share on other sites

1.    Thank you so much, DavidDawn, for your response.
.
2.    Yes, I have a basic enough knowledge of HTML and PHP.
.
3.    For example, my www or document root is

/home/cynthie/public_html/wish/

and from a file on the same root I could simply say

<img src="beautifuljulie.jpg" />

or on the browser I could type

 http://www.wishtimer.com/beautifuljulie.jpg

but one of the security suggestions in Effortless e-Commerce is to try placing some files or images one step below/behind the root folder, which in my case would be

/home/cynthie/public_html/

which, with the image would give me this:

/home/cynthie/public_html/beautifuljulie.jpg

So, how do I access this file (beautifuljulie.jpg) from a file in the root folder, whether a php or html file?
Thanks again.
 - Cythie

Share this post


Link to post
Share on other sites

David had provided the answer (thanks, David!) but to provide a bit more detail, your IMG SRC value would be something like show_image.php?id=X. The show_image.php file would validate the ID value (probably against a database), find the image file on the server, and then provide the image itself. This is known as a proxy script. I think there's an example in the book for serving PDF files.

Share this post


Link to post
Share on other sites

I wish to say that I spent a bit more time with the book, paying particular attention to the 'view-pdf.php' script which begins on page 144, and it finally sank in. I get it now; it all makes sense what you all said in the replies, and I could nicely place a jpg file behind my root folder and pull it up just like that! Thanks again. I'm a huge fan!!
 - Cynthie.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...