Re: How can I display an image within a script?
| From: | ed at homes2see dot com | Date: | Wed, 16 Jul 2003 01:09:14 +0000 |
| Subject: | Re: How can I display an image within a script? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155357@lists.php.net to get a copy of this message | ||
Yes, the method below would work just fine if you only needed to display
one image. Trying it on a second image within the same generated page
would give you a "headers already sent" error.
Ed
> Ok, assuming that the image files are outside the public web tree and
> you can read them with a script. You will have to write a php script
> that will read the file (sending the appropriate headers).
>
> So your script will generate html like
> <img src="/showimage.php?file=filename.jpg">
>
> then showimage.php will do something:
> header('content-type: appropricate/type');
> // content-length would be good
> readfile($file);
>
> HTH Curt --