Jump to content

Generated Images within Div tag


debug

Recommended Posts

Hi-

 

Yesterday I wrote a quick script to generate an image using the GD graphics library and it works great however now when I try to put the code into a Div tag I'm getting a error stating that the header has already been set and then it churns out a load of garbage (which I assume is the png file in its raw format).

 

any ideas how I could embed my generated image into a div tag?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/152229-generated-images-within-div-tag/
Share on other sites

If you look in the PHP that generates your image, you should see a line similar to:

 

header("Content-Type: image/png");

 

This is defining the content type as an image, half way through the file, which obviously the surrounding HTML is definitely not. You need to include the generated image externally, which you can do using the HTML <img> tag, like so:

 

<img src="gen_img.php" alt="" />

 

Just place the PHP that generates the image within the "gen_img.php" file (or whatever you wish to call it).

 

By the way this isn't a JavaScript problem...

 

Adam

Archived

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

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