Jump to content

Just want to display to broswer with "imagejpeg"


lindylex

Recommended Posts

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>

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);

 

 

?>

 

 

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

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.