Thread: Check RAW data
View Single Post

  #3 (permalink)  
Old 04-20-2008
Regular email
 
Posts: n/a
Default Re: [PHP] Check RAW data

> On Sun, 2008-04-20 at 15:52 +0200, rb wrote:
>> I'm getting from an external source a PNG image in raw format (encoded in
>> base64).
>>
>> And with this code I'll echo on the screen.
>>
>> ------
>> $img=base64_decode($_POST['img']);
>>
>> header("Content-type: image/png");
>> echo $img;
>> ------

>
> A quick way would be to try and make an image with the GD library.
> Something like:
> if (imagecreatefromstring($img)) {
> header("Content-type:image/png");
> echo $img;
> }


Perhaps check the image header matches the correct format for a PNG image.

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+


Reply With Quote