Resizing image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Resizing image

Post by Ree »

I'm trying GD library atm, and for some reason I cannot upload/resize images. Here's what I have:

Code: Select all

<?php

if (isset($_FILE['img1']))
{
  list($width, $height) = getimagesize($_FILE['img1']['tmp_name']);
  $new_width = $width * 0.5;
  $new_height = $height * 0.5;
  $img1 = imagecreatefromjpeg($_FILE['img1']['tmp_name']);
  $img1_new = imagecreatetruecolor($new_width, $new_height);
  imagecopyresampled($img1, $img1_new, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  imagejpeg($img1_new, 'images/boogie.jpg');
  echo '<img border="0" src="images/boogie.jpg">';
}

?>

<form enctype="multipart/form-data" action="gd.php" method="post">
  <input type="file" name="img1"></br>
  <input type="submit" value="Go">
</form>
What am I doing wrong?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_FILE :arrow: $_FILES
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

omg omg omg!! :D
Post Reply