Re: displaying graphics
| From: | Johan Hanson | Date: | Thu, 31 Aug 2000 18:53:32 +0000 |
| Subject: | Re: displaying graphics | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2534@lists.php.net to get a copy of this message | ||
Mike Hammonds wrote:
>
> ** Reply Requested When Convenient **
>
> Anybody have a good script that will allow me to get an image from MySQL and than display it on
> a web page?
Here is what I do. I use Apache and mod_rewrite to let an URL like
"images/<number>.gif"
be translated into a request for "image.php?img=<number>". That way, the user
can save the
file from her browser without it mangling the file name.
The configuration directive is:
RewriteRule ^/images/(.+)\.gif$ image.php?img=$1 [L]
My script outputs the correct mime type in the headers and 'echo'es the gif file
directly.
Just make sure that you don't echo anything else than the gif file, such as a
newline
at the end of your script.
For more info, look in the file "features.images.html" in your PHP
documentation.
/ Johan
-- johan@tiq.com -- http://www.obsession.se/johan/ --