Mateen Posted October 27, 2010 Share Posted October 27, 2010 hi evry bdy i m new to php here is my big problem im trying to display images and resize but header tag in php not working here is my code <?php header('Content-type: image/jpeg'); $new_width = 200; $new_height = 200; $files = glob("images/*.*"); //print_r($files); //for ($i=0; $i<count($files); $i++) { $filename= $files[0]; print $filename."<br />"; list($width, $height) = getimagesize($filename); echo "width is".$width." and height is ".$height; echo '<img src="'.$filename.'" alt="random image" />'."<br /><br />"; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); //} ?> if i m commenting header in line 3 then it is displaying garbage value if i m not commenting then it is displaying filename as string ... i wanna resize image plz hlp me..... Quote Link to comment https://forums.phpfreaks.com/topic/216988-headercontent-type-imagejpeg-not-working/ Share on other sites More sharing options...
trq Posted October 27, 2010 Share Posted October 27, 2010 You cannot echo html within an image itself which is what sending the jpeg header does, makes this code an image. Quote Link to comment https://forums.phpfreaks.com/topic/216988-headercontent-type-imagejpeg-not-working/#findComment-1127039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.