lindylex Posted December 28, 2007 Share Posted December 28, 2007 I am studying PHP and all I want to do is output a jpg file to the browser. This is what I have tried. header("Content-Type: image/jpeg"); $img="large/img_1.jpg"; $please_work=imagecreatefromjpeg($img); imagejpeg($please_work); imagedestroy($please_work); When I go to the browser I see nothing but text "http://localhost/php_study/manipulate_image/image_manipulation.php". When I view source I get this. I know for sure that the image was not embedded. Any ideas anyone? Thanks <html><body><img alt="http://localhost/php_study/manipulate_image/image_manipulation.php" src="http://localhost/php_study/manipulate_image/image_manipulation.php"></body></html> Quote Link to comment https://forums.phpfreaks.com/topic/83434-just-want-to-display-to-broswer-with-imagejpeg/ Share on other sites More sharing options...
teng84 Posted December 28, 2007 Share Posted December 28, 2007 did you use header eg. header('Content-Type: image/jpeg'); header('Content-Disposition: inline; filename=file.jpg); Quote Link to comment https://forums.phpfreaks.com/topic/83434-just-want-to-display-to-broswer-with-imagejpeg/#findComment-424459 Share on other sites More sharing options...
lindylex Posted December 28, 2007 Author Share Posted December 28, 2007 Teng84, I tried but it did the same thing. This is what I have below. <?php header('Content-Type: image/jpeg'); header('Content-Disposition: inline; filename=file.jpg'); $please_work=imagecreatefromjpeg($img); imagejpeg($please_work); imagedestroy($please_work); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83434-just-want-to-display-to-broswer-with-imagejpeg/#findComment-424536 Share on other sites More sharing options...
lindylex Posted December 28, 2007 Author Share Posted December 28, 2007 Thanks for you help I got it to work, like this. <?php header('Content-Type: image/jpeg'); $img="large/img_1.jpg"; $please_work=imagecreatefromjpeg($img); header('Content-Disposition: inline; filename=$please_work'); imagejpeg($please_work); imagedestroy($please_work); exit; ?> Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/83434-just-want-to-display-to-broswer-with-imagejpeg/#findComment-424542 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.