jasonc Posted August 2, 2009 Share Posted August 2, 2009 i have my page and use the include method to try to add the image created in the included file, but it just shows all the strange characters and not the image. i want to hopefully have it show within a table set i have how is this done? Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2009 Share Posted August 2, 2009 You must use an <img src="the_URL_of_an_image_here" alt=""> HTML tag for each image. You cannot put the raw image data in the middle of HTML. The php code that outputs the content type header followed by the imagepng($im); must be in its' own file and the URL of that file is put into the src="..." attribute of the <img tag. Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/#findComment-889134 Share on other sites More sharing options...
jasonc Posted August 2, 2009 Author Share Posted August 2, 2009 so there is no other way around this? Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/#findComment-889135 Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2009 Share Posted August 2, 2009 Images on a web page - http://w3schools.com/html/html_images.asp You have got to get the HTML correct before you use php to output HTML or media content. Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/#findComment-889148 Share on other sites More sharing options...
jasonc Posted August 2, 2009 Author Share Posted August 2, 2009 ok i have added this to my script... $newimage = imagepng($im); // previsouly just imagepng($im); $temp_folder = "temp_images/"; $randomname = $temp_folder . "temp_image_".rand(10, 999999) . ".png"; while (file_exists($randomname)) { $randomname = $temp_folder . "temp_image_".rand(10, 999999) . ".png"; } $fp = fopen($randomname, 'w'); fwrite($fp, $newimage); fclose($fp); imagedestroy($im); but now i get the strange characters and not the image on the page. the image contains only one byte and nothing else. Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/#findComment-889157 Share on other sites More sharing options...
jasonc Posted August 3, 2009 Author Share Posted August 3, 2009 solved i used imagepng($im, "filename.png"); Link to comment https://forums.phpfreaks.com/topic/168553-how-to-import-an-imagepngim-within-my-page/#findComment-889184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.