Re: placing data outside the server root
| From: | Mike | Date: | Mon, 15 Apr 2002 15:53:05 +0000 |
| Subject: | Re: placing data outside the server root | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93044@lists.php.net to get a copy of this message | ||
Well, you couldn't put an image outside the document root, and use a normal
HTML tag (<img src="image.gif">) obviously, because the browser wouldn't be
able
to read it...
but
you could do "<img src="fetchimage.php?image=image.gif">" and the program
fetchimage could go to a directory (not in your document root) and look for
the
image "image.gif". If it found it, it could pass back the appropriate
Content-Type
header (in this case image/gif), and then open the image as a file, and
start
spiting back the binary of the image to the browser.
something like this:
$file = "/path/to/images/$image";
$imagep = @fopen($file,"r");
if ($imagep)
header("Content-type: image/gif");
while(!feof($imagep))
$buffer = fread($imagep,4096);
echo $buffer;
}
fclose($imagep);
}
Something like that.
Good luck,
Mike
mike@deadmime.com
> Hi there,
>
> is it possible to place data like images outside the server root, and if
so
> does php still get access to them for displaying?
>
> thanx, Andy
>
>
>
>