On Sunday 04 February 2001 05:53, you wrote:
> Hi all,
>
> I'm trying to make a demonstration script (using PHP) that demonstrates
> the use of MIME types in HTTP headers. It should send the Content-Type
> header and than sends an image to the browser in hex.

What do you mean with "in hex"? Hex is a number system. It only exists to 
make handling binary data easier for humans.

> I run the script in my browser and get the bare decimal values
> displayed and not the GIF image:

Aha. So you just want to "send the image".

> I also tried to use:
> header("Content-type: image/gif");
> But no success.
> I don't want to use the header() function cause it doesn't help my
> demostration script show the workings.

Well, you *need* the header ("Content-type: image/gif"); to tell the 
browser that you're sending a gif. It can not determine that by itself.

If you don't send the header the browser will try to interpret you gif 
image as HTML code, which usually gives, well, fascinating results :)

> // 7x1 pixel GIF image data
> $img = array (
>     0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x07, 0x00, 0x01, 0x00, 0xF7,
> 0x00, 0x00, 0x00, 0x00, 0x00,
>     0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00,
> 0x80, 0x80, 0x00, 0x80, 0x00,

[...]

> ) ;

> // Write content type to browser
> echo "Content-Type: image/gif\n\n";
>
> // Write GIF image data to browser
> foreach ($img as $val){
>       echo $val;
> }

Try
echo pack ('c*', $img);

Or if that doesn't work:

foreach ($img as $val) {
    echo pack ('c', $val);
}


-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

...10001000110101011010101101011110111010113...????

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to