Re: images outside of document root

From: Date: Tue, 06 Jul 2004 20:20:16 +0000
Subject: Re: images outside of document root
Groups: php.general 
Request: Send a blank email to php-general+get-189819@lists.php.net to get a copy of this message
I may do that, but the 'showimage.php' file then has to be in the document root, and can be attacked a LOT. I have found ways to do inline images, without javascript, I believe. Curt Zirzow <php-general@zirzow.dyndns.org> wrote: * Thus wrote Dennis Gearon:
I want to keep an entire library OUTSIDE of the document root. The library includes some imgages. How can I have the browser include the imageges? I've hard of BASE64'ing the images into the header and decoding them using javascript. Is this the best way? Where is code to do that?
no, its probably the worst way. To have the browser reference images outside the document root you'll have to create a php wrapper function that decides on what to do: <img src="/showimage.php?file=foobar.jpg"> showimage.php: <?php $file = $_GET['file']; // authentication if needed... // check for valid file, etc.. header('Content-Type: image/jpeg'); // send right content type readfile($path_outside_docroot . $file);

« previous php.general (#189819) next »