|
Posted by Mohawk Mawk on 06/08/07 19:43
i had the same problem that i would only see the weird text when i
tried outputing an image
check this :)
http://bjorntoday.com/pico.php?ID=20
this outputs a string as an images i can use the <img> tag no problem
because of header()
<?
header('Content-type: image/jpg'); //watch out that you have no white
spaces before <? or header throws a fit
$IMG= //your image string
print $IMG;
?>
i got my pictures saved in a database as blob so this is very
practical, yet i had the problem that the pictures where not caching,
so i got a lil help from the php manual, this works
<?
// Checking if the client is validating his cache and if it is
current.
if (isset($headers['If-Modified-Since']) &&
(strtotime($headers['If-Modified-Since']) == $TIME)) {// Client's
cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $TIME).'
GMT', true, 304);
} else {// Image not cached or cache outdated, we respond '200 OK'
and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $TIME).'
GMT', true, 200);
header('Content-type: image/jpg');
print $IMG;
}
?>
$TIME in my case is stored in the database as well.
[Back to original message]
|