this is a function i wrote to upload an image, create a thumb with a height of 80 and resizes the width proportionately. it upload the image and names the thumb with a _t at the end. hope this helps.
$filename would be the temporary file name ( $_FILES['somefile']['tmp_name'] )
$name would be what you want it to be named
PHP Code:
<?
function getRootPath(){
return "/home/user/public_html/";
}
function uploadPhoto($filename,$name){
$name = stripslashes($name);
list($width, $height) = getimagesize($filename);
$percent = 80 / $height;
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$newfile = getRootPath()."images/photos/".$name;
move_uploaded_file($filename,$newfile);
chmod($newfile, 0644);
$array = explode(".",$name);
imagejpeg($image_p, getRootPath()."images/photos/".$array[0]."_t.".$array[1]);
}
?>