Re: files outside of the web tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/27/2011 12:08 PM, Jim Giner wrote:
> I have managed to build include files and store them above my public folder 
> and the called pages manage to find them from the public folder and properly 
> include them.  My problem is with the html src= attribute.  I have uploaded 
> photos to  be included in my web pages and I didn't want them in the web 
> tree so I moved them above it also. I use php to get the root folder's name 
> and then I add "../photos/" to the filename's path, but now my tags can't 
> find them.  Can I not do this? 
> 
> 

One way to do this is to have a PHP file as the image source.  The PHP
file would grab the image outside of the web root and echo it along with
the proper headers.  This is the same principle as storing the binary
image data in a database.

<img src="photo.php?name=mydog.png">


//photo.php
$file = '/path/to/photos/' . basename($_GET['name']);
$type = mime_content_type($file);
header('Content-type: $type');
readfile($file);

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux