Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I call on an Image from my server but outside the htdocs dir?

Status
Not open for further replies.

rmfrance

Programmer
Nov 1, 2001
9
0
0
GB
For security, I would like to be able to call on images that are not stored within the htdocs directory.
I know it's possible to call external files this way, but is it possible with images. The following is how my server directory is set up...

images/here.gif
usr/htdocs/webpages.htm

...could anyone please help with the code needed to call on this image?
 
I'm assuming that /usr/htdocs is the "document root" for your web server? In order to access files outside of that, you would execute a cgi program, and have that program access the files. For example, you can have an IMG tag call a cgi script to return an image:
Code:
<img src=&quot;/cgi-bin/getpic.pl?name=pic1.gif&quot; ...>
. Your cgi program would print an appropriate content type header for the type of image file (image/gif or image/jpeg) and then open the appropriate image file, read it, and print it. This is part of the technique used to prevent people from linking to images on your server. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top