resize image and upload it to ftp (problem)

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
jasmineh
Forum Newbie
Posts: 1
Joined: Thu Jul 20, 2006 8:15 am

resize image and upload it to ftp (problem)

Post by jasmineh »

hi!
i'm using this code to resize an image posted in a form:
php:

Code: Select all

<?
$uploadedfile = $_FILES['images']['tmp_name'][$key];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newwidth=600;
$newheight=($height/$width)*600;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "tmp/". $_FILES['images']['tmp_name'][$key];
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
?>
Before i was using this code to upload to my ftp images posted in a form:

Code: Select all

$add = $newdir.$filename;
ftp_put($id_con, $add, $_FILES['images']['tmp_name'][$key], FTP_BINARY);
Everything was working separately ok. But what i'm not achieving is to weld both codes to, in one step, resize and post images to my ftp.
Any ideas?
thanx
Martin
Post Reply