A horsie named Phil Powell demonstrated surprising intellligence and
its ability to use morse code on Sun, 07 Sep 2003 20:41:53 -0500 when
it tapped <98R6b.135680$xf.46220@lakeread04> with its hoof:
Thanx, but I can't use header() because the image is embedded inside
text/html content type.
The text/html content only links to images. It does not
contain them as such. So you would have a PHP page
that creates the text/html content, and that content
would contain IMG elements that link to another PHP
script that generates images only. That script is
free to use header() to specify an image type.
In the following example I got lazy and decided
to put everything into one file:
<?php
// PHP 4.0.5
error_reporting(E_ALL & ~E_NOTICE);
$s = & $HTTP_SERVER_VARS;
if (empty($HTTP_GET_VARS['img'])):
?>
<title> Image Show </title>
<p> This page should show an image.
Here it is:
</p>
<img src='<?php echo "$s[PHP_SELF]?img=myimage%2Epng"; ?>'
alt='A nice image'>
<?php
else:
$imgfile = $HTTP_GET_VARS['img'];
$tag = fopen($imgfile, 'rb')
or die('Can\'t read image file');
if ($tag) {
header('Content-type: image/png');
fpassthru($tag);
}
endif;
?>
I'll leave separating this script into its various
parts as an exercise for you :-)
However, you will probably notice that separation is
not strictly necessary.
This message is under the GPL.