I am trying to learn how to access files outside of the site root folder. I found an interesting post on SO HERE that provided some very simple code:
"if you want to provide access to a file outside of the document root, you'll have to do it via a script. The simplest method is to have:
image.php:
<?php
header('Content-type: image/jpeg');
readfile('/path/to/picture/outside/doc/root/file.jpg');
?> //original post was missing this closing tag
and in your html:
<img src="image.php">
"
I also read HERE anout the proper path on a cPanel server running Apache (I am running Apache 2.0) which was listed as:
/var/www/username
And I tried all that, amending the first code above with the correct path and my own account username. I upload the image.php
file and the page that calls it and when I test the page, I get nada. A look at the source code and also examine the element in Firebug and it shows what one might expect:
<img src="image.php" />
So...what am I missing here? The original question had this solution checked as a valid answer.
I have seen mentions of mod_rewrite
all day (I have been at this for the entire day) and am not certain if that is valid here or not.
Many thanks in advance for the help!