I have a script, which I've called test-loadpic.php and some pages
reference it by means of
<img src="test-loadpic.php?sourcepic=$picNum">
where $picNum stores a number. This part itself works fine.
test-loadpic.php uses the "sourcepic" GET variable to reference a file
on disk, get it's file/MIME type, transmit the headers and then the raw
image. The important code is below:
header ("Content-type: $fileMIME");
header ("Content-Length: ".filesize($filePath.$fileName));
$fp = fopen ($filePath.$fileName, "rb");
$er = fpassthru ($fp);
fclose($fp);
$fileMIME is the MIME type of the image, of course ("image/gif" or
"image/jpeg" in my case). $filePath and $fileName point to the image
(ex: "/var/www/phptest/images/" and "filter.jpg").
Is this all I need to properly transmit an image?
This seems to work fine in IE but sometimes Netscape 7.1 tries to
download the image instead of showing it. Are my headers incorrect? I
suspect there's a glitch in my scripting that IE can tolerate but
Netscape can't. Is there a proper "end of image" code I need to send to
the browser that isn't included at the end of the images themselves?
Thank you in advance to anyone with some insight.
--
- Michael J. Astrauskas