Jump to content

Archived

This topic is now archived and is closed to further replies.

ReVeR

Headers

Recommended Posts

Hello.
I have a set up of using 2 php files for the top part of the web site and another file for bottom part.
Now, in the bottom part i wanted to generate an image with php so i have the following code:
[code]
$ad=ImageCreateFromJPEG($field);
            Header('Content-type: image/jpeg');
            ImageJPEG($ad);
[/code]
where filed points to an image on the hd.
i get the following error:
[code]
Warning: Cannot modify header information - headers already sent by (output started at C:\Apache Group\Apache2\htdocs\web_business_2\header.php:44) in C:\Apache Group\Apache2\htdocs\web_business_2\lower.php on line 155
[/code]
I know i am sending headers in the header.php (top part of the web), but why can;t i send them from the bototm part too? note that both of these 2 parts are included in test.php which basicly uses the header and the lowert php to defined the web site and then puts its own code in between.

Any ideas how to bypass teh error?
Thx

Share this post


Link to post
Share on other sites
You can not send both regular text/html headers and image headers for the same document. It can either be a webpage, or an image, not both.

The reason you get the headers already sent message is because some output has already been sent to the browser...if your code is at the bottom of your page, that makes sense.

If you are wanting to generate an image in php, then display it back as a part of a webpage, you need to use an img tag in your html, then for the src attribute, use your php image page:

[code]<h1>some html</h1><br />
<img src="image.php" alt="this is an image dynamically generated by php">[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.