Jump to content

vv1984

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vv1984's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi to everyone, I've made a (very) simple script that takes an uploaded image, resizes it and then returns it to the output. But while the image is correctly showed in the browser if I try to save it (save image as..), I find it's only 8kb. And then I find it's not the image, but my php file... why? I think there's something wrong with headers, but i've really tried everything.. I try to post the code: <?php $img = imagecreatefromjpeg('upload_img/'.$_FILES['image']['name']); //Image width and height $sx = imagesx($img); $sy = imagesy($img); //Image resize $resized_img = imagecreatetruecolor(542,409); imagecopyresized($resized_img, $img, 0, 0, 0, 0, 542,409, $sx, $sy); //Setting headers header('Content-type: image/jpeg'); header('Content-Length: '.filesize(imagejpeg($resized_img))); header('Content-Disposition: inline; filename="downloaded.jpg"'); //Return the output imagejpeg($resized_img, 'downloaded.jpg'); imagedestroy($resized_img); //Deleting the old file unlink('upload_img/'.$_FILES['image']['name']); exit; ?>
×
×
  • 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.