Jump to content

Headers


ReVeR

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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.