Can you provide a URL so I can see if I can print it from my browsers?
Can you confirm that filesize is definitely producing a result?
Bill Bolte wrote:
I've put this on my fetch.php
<?php
header('Content-Type: image/gif');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. filesize('image/'.$_GET['id']));
readfile('image/'.$_GET['id']);
unlink('image/'.$_GET['id']);
?>
I can see the image but can't print it. Am I doing the filesize
correctly?
-----Original Message-----
From: Kevin Smith [mailto:kevin@xxxxxxxxxxxxxxx]
Sent: Monday, March 05, 2007 4:40 PM
To: Bill Bolte
Cc: php-windows@xxxxxxxxxxxxx
Subject: Re: base64 encoded images and printing
Hi Bill,
This is what I've used for the last 4 years or so and works in every
browser that I've come across, obviously the data is being called from a
database instead.
<?php
//snippet
$query = "select bin_data, file_type from content_images where
image_id=".$_GET['id'];
$result = mysql_query($query);
$line = mysql_fetch_array($result) ;
$data = $line[0];
$file_type = $line[1];
header("Content-Type: $file_type");
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. strlen($data));
print($data);
?>
<img src="foobar.php?id=12345" />
The important thing here is the headers "Content-Transfer-Encoding" and
"Content-Length", which is why IE6 does not work, as without these the
browser gets all upset that it doesn't know the true size of the image
not the proper encoding of the file, this obviously being an image.
It's good practice to put these headers in anyway.
Hope this helps.
Regards,
Kevin Smith
Bill Bolte wrote:
Update, I have it working in IE7 but not IE6. I can view it in both
IE6-7, but it only prints in IE7. here's what I'm doing...
<?php
//snippet
$outputfile = $shipid.'.gif';
$ifp = fopen('tmp/'.$outputfile, "wb"); fwrite($ifp,
base64_decode($image)); fclose($ifp); echo '<img
src="fetch.php?id='.$outputfile.'" />'; ?>
fetch.php is thus, read file and delete:
<?php
//snippet
header('Content-Type: image/gif');
readfile('image/'.$_GET['id']);
unlink('image/'.$_GET['id']);
?>
anyone have any other ideas to try?
__________________
-----Original Message-----
From: Bill Bolte [mailto:billb@xxxxxxxxxxxxxxxx]
Sent: Monday, March 05, 2007 9:29 AM
To: php-windows@xxxxxxxxxxxxx
Subject: base64 encoded images and printing
in a nutshell, i'm displaying a base64 encoded image (that is being
parsed from a remote xml file) in the browser doing a simple header
output:
<?php
header('Content-Length: '.$length);
header('Content-Type: image/gif');
echo base64_decode($image);
?>
it will print fine with Firefox but nothing in IE (just a box with an
x in the corner). didn't realize that IE wouldn't print these. am i
stuck with having to save the image to the server for IE to be able to
print it? i didn't really want to have to save these images out as
they are temporary.
Bill
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php