base64 encoded images and printing

base64 encoded images and printing

am 05.03.2007 16:28:58 von Bill Bolte

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:

header('Content-Length: '.$length);=20
header('Content-Type: image/gif');=20
echo base64_decode($image);=20
?>

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.
=20
Bill

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: base64 encoded images and printing

am 05.03.2007 23:21:39 von Bill Bolte

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...

//snippet
$outputfile =3D $shipid.'.gif';
$ifp =3D fopen('tmp/'.$outputfile, "wb");
fwrite($ifp, base64_decode($image));
fclose($ifp);
echo '';
?>

fetch.php is thus, read file and delete:

//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@hightouchinc.com]=20
Sent: Monday, March 05, 2007 9:29 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] 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:

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.
=20
Bill

--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: base64 encoded images and printing

am 05.03.2007 23:40:13 von Kevin Smith

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.

//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);
?>


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...
>
> > //snippet
> $outputfile = $shipid.'.gif';
> $ifp = fopen('tmp/'.$outputfile, "wb");
> fwrite($ifp, base64_decode($image));
> fclose($ifp);
> echo '';
> ?>
>
> fetch.php is thus, read file and delete:
>
> > //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@hightouchinc.com]
> Sent: Monday, March 05, 2007 9:29 AM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] 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:
>
> > 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
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: base64 encoded images and printing

am 06.03.2007 02:39:57 von bedul

umm.. sry this kind oot but might related
do you ever upload pic to imageshack? one of their fitur was zip upload.
where you send a zip (contain n pic inside) where same as u upload many
pic.. i wonder what the script.. anyone have it?

----- Original Message -----
From: "Kevin Smith"
To:
Cc:
Sent: Tuesday, March 06, 2007 5:40 AM
Subject: Re: [PHP-WIN] base64 encoded images and printing

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: base64 encoded images and printing

am 06.03.2007 16:11:36 von Bill Bolte

I've put this on my fetch.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']);=20
?>
I can see the image but can't print it. Am I doing the filesize
correctly?


-----Original Message-----
From: Kevin Smith [mailto:kevin@netsmith.ltd.uk]=20
Sent: Monday, March 05, 2007 4:40 PM
To: Bill Bolte
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] 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.

//snippet
$query =3D "select bin_data, file_type from content_images where
image_id=3D".$_GET['id'];
$result =3D mysql_query($query);

$line =3D mysql_fetch_array($result) ;
$data =3D $line[0];
$file_type =3D $line[1];

header("Content-Type: $file_type");
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. strlen($data));
print($data);
?>


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. =20
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=20
> IE6-7, but it only prints in IE7. here's what I'm doing...
>
> > //snippet
> $outputfile =3D $shipid.'.gif';
> $ifp =3D fopen('tmp/'.$outputfile, "wb"); fwrite($ifp,=20
> base64_decode($image)); fclose($ifp); echo ' > src=3D"fetch.php?id=3D'.$outputfile.'" />'; ?>
>
> fetch.php is thus, read file and delete:
>
> > //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@hightouchinc.com]
> Sent: Monday, March 05, 2007 9:29 AM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] base64 encoded images and printing
>
> in a nutshell, i'm displaying a base64 encoded image (that is being=20
> parsed from a remote xml file) in the browser doing a simple header
> output:
>
> > 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=20
> x in the corner). didn't realize that IE wouldn't print these. am i=20
> 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=20
> they are temporary.
> =20
> Bill
>
> --
> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
> =20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: base64 encoded images and printing

am 06.03.2007 16:22:31 von Kevin Smith

--------------070901090908010501060801
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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
> > 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@netsmith.ltd.uk]
> Sent: Monday, March 05, 2007 4:40 PM
> To: Bill Bolte
> Cc: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] 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.
>
> > //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);
> ?>
>
>
> 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...
>>
>> >> //snippet
>> $outputfile = $shipid.'.gif';
>> $ifp = fopen('tmp/'.$outputfile, "wb"); fwrite($ifp,
>> base64_decode($image)); fclose($ifp); echo ' >> src="fetch.php?id='.$outputfile.'" />'; ?>
>>
>> fetch.php is thus, read file and delete:
>>
>> >> //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@hightouchinc.com]
>> Sent: Monday, March 05, 2007 9:29 AM
>> To: php-windows@lists.php.net
>> Subject: [PHP-WIN] 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:
>>
>> >> 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
>>
>>
>>
>
>

--------------070901090908010501060801--

Re: base64 encoded images and printing

am 06.03.2007 17:01:13 von Kevin Smith

--------------070409040501070308020103
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

This site uses the same method as I previously detailed. Can you try a
print preview and tell me if you can see the images.... Please ignore
the fact that a print preview of this page looks bloody awful!

http://www.roh.nhs.uk/view_article.php?article_id=30

Bill Bolte wrote:
> It's behind a login, so I can't give you a url at the moment. I'll
> check on the filesize and see what I'm getting...
>
> ------------------------------------------------------------ ------------
> *From:* Kevin Smith [mailto:kevin@netsmith.ltd.uk]
> *Sent:* Tuesday, March 06, 2007 9:23 AM
> *To:* Bill Bolte
> *Cc:* php-windows@lists.php.net
> *Subject:* Re: [PHP-WIN] base64 encoded images and printing
>
> 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
>> >> 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@netsmith.ltd.uk]
>> Sent: Monday, March 05, 2007 4:40 PM
>> To: Bill Bolte
>> Cc: php-windows@lists.php.net
>> Subject: Re: [PHP-WIN] 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.
>>
>> >> //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);
>> ?>
>>
>>
>> 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...
>>>
>>> >>> //snippet
>>> $outputfile = $shipid.'.gif';
>>> $ifp = fopen('tmp/'.$outputfile, "wb"); fwrite($ifp,
>>> base64_decode($image)); fclose($ifp); echo ' >>> src="fetch.php?id='.$outputfile.'" />'; ?>
>>>
>>> fetch.php is thus, read file and delete:
>>>
>>> >>> //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@hightouchinc.com]
>>> Sent: Monday, March 05, 2007 9:29 AM
>>> To: php-windows@lists.php.net
>>> Subject: [PHP-WIN] 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:
>>>
>>> >>> 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
>>>
>>>
>>>
>>
>>

--------------070409040501070308020103--

RE: base64 encoded images and printing

am 06.03.2007 17:22:31 von Bill Bolte

------_=_NextPart_001_01C7600B.A428B5B6
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

yes i could print the images. maybe it's a cache issue (had that happen
before). let me do some experimenting here.

________________________________

From: Kevin Smith [mailto:kevin@netsmith.ltd.uk]=20
Sent: Tuesday, March 06, 2007 10:01 AM
To: Bill Bolte
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] base64 encoded images and printing


This site uses the same method as I previously detailed. Can you try a
print preview and tell me if you can see the images.... Please ignore
the fact that a print preview of this page looks bloody awful!

http://www.roh.nhs.uk/view_article.php?article_id=3D30

Bill Bolte wrote:=20

It's behind a login, so I can't give you a url at the moment.
I'll check on the filesize and see what I'm getting...

________________________________

From: Kevin Smith [mailto:kevin@netsmith.ltd.uk]=20
Sent: Tuesday, March 06, 2007 9:23 AM
To: Bill Bolte
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] base64 encoded images and printing
=09
=09
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?
=09
Bill Bolte wrote:=20

I've put this on my fetch.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']);=20
?>
I can see the image but can't print it. Am I doing the
filesize
correctly?
=09
=09
-----Original Message-----
From: Kevin Smith [mailto:kevin@netsmith.ltd.uk]=20
Sent: Monday, March 05, 2007 4:40 PM
To: Bill Bolte
Cc: php-windows@lists.php.net
Subject: Re: [PHP-WIN] base64 encoded images and
printing
=09
Hi Bill,
=09
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.
=09
//snippet
$query =3D "select bin_data, file_type from
content_images where
image_id=3D".$_GET['id'];
$result =3D mysql_query($query);
=09
$line =3D mysql_fetch_array($result) ;
$data =3D $line[0];
$file_type =3D $line[1];
=09
header("Content-Type: $file_type");
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. strlen($data));
print($data);
?>

=09
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. =20
It's good practice to put these headers in anyway.
=09
Hope this helps.
=09
Regards,
Kevin Smith
=09
Bill Bolte wrote:
=20

Update, I have it working in IE7 but not IE6. I
can view it in both=20
IE6-7, but it only prints in IE7. here's what
I'm doing...
=09
//snippet
$outputfile =3D $shipid.'.gif';
$ifp =3D fopen('tmp/'.$outputfile, "wb");
fwrite($ifp,=20
base64_decode($image)); fclose($ifp); echo '
src=3D"fetch.php?id=3D'.$outputfile.'" />'; ?>
=09
fetch.php is thus, read file and delete:
=09
//snippet
header('Content-Type: image/gif');
readfile('image/'.$_GET['id']);
unlink('image/'.$_GET['id']);
?>
=09
anyone have any other ideas to try?
__________________
=09
-----Original Message-----
From: Bill Bolte [mailto:billb@hightouchinc.com]
Sent: Monday, March 05, 2007 9:29 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] base64 encoded images and
printing
=09
in a nutshell, i'm displaying a base64 encoded
image (that is being=20
parsed from a remote xml file) in the browser
doing a simple header
output:
=09
header('Content-Length: '.$length);
header('Content-Type: image/gif');
echo base64_decode($image);
?>
=09
it will print fine with Firefox but nothing in
IE (just a box with an=20
x in the corner). didn't realize that IE
wouldn't print these. am i=20
stuck with having to save the image to the
server for IE to be able to
=20

=09
=20

print it? i didn't really want to have to save
these images out as=20
they are temporary.
=20
Bill
=09
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit:
http://www.php.net/unsub.php
=09
=20
=20

=09
=20


------_=_NextPart_001_01C7600B.A428B5B6--