Jump to content

header('Content-type: image/jpeg'); not working??


Mateen

Recommended Posts

 

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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