Re: How can I display an image within a script?
| From: | Curt Zirzow | Date: | Tue, 15 Jul 2003 20:13:54 +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-155312@lists.php.net to get a copy of this message | ||
Dan Anderson <dan@mathjunkies.com> wrote:
> Because of restrictive safe mode settings I cannot display images from
> their folder. Is there a way to embed them within a web page?
I'm not entirely clear what you mean by not being able to display images
from their folder, can you explain that more. HTML doesn't allow for
embeded images.
>
> i.e.
>
> <?php
> print "<IMAGE START>\n";
> readfile('image.jpeg');
> print "</IMAGE END>\n";
> ?>
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
--