I have been trying to get the below code working, it is a mix of two seperate files one which uploads files (red code) which works and thumbnail generation which isnt working yet and i cant see why. all the file paths are correct, any help would be aprishiated greatly as i just cant see the problem. I am very new to PHP and feel it could be something very simple that i just dont know.
<?php
$thumbw=100; //The Width Of The Thumbnails $nw
$thumbh=75; //The Height Of The Thumbnails $nh
if ( $_FILES['image'] ['name'] != "")
{
$uploadedFile = $FILES['image']['tmp_name'];
$newFile = $SERVER['DOCUMENT_ROOT']."/shop/admin/images/".$FILES['image']['name'];
$newtempfile = $SERVER['DOCUMENT_ROOT']."/shop/admin/images/thumbs/".$_FILES['image']['name'];
}
move_uploaded_file($uploadedFile, $newFile);
$image = $uploadedfile;
$dimensions = GetImageSize($image);
$thname = "$thumbpath/$img_name";
$width=$dimensions[0];
$height=$dimensions[1];
$tempimage = ImageCreateFromJpeg($image);
$thumb=ImageCreateTrueColor($thumbw,$thumbh);
$wm = $width/$thumbw;
$hm = $height/$thumbh;
$h_height = $thumbh/2;
$w_height = $thumbw/2;
if($width > $height){
$adjusted_width = $width / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;
ImageCopyResampled($thumb,$tempimage,-$int_width,0,0,0,$adjusted_width,$thumbh,$width,$height);
ImageJPEG($thumb,$thname,95);
}elseif(($width < $height) || ($width == $height)){
$adjusted_height = $height / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;
ImageCopyResampled($thumb,$tempimage,0,-$int_height,0,0,$thumbw,$adjusted_height,$width,$height);
ImageJPEG($thumb,$thname,95);
}else{
ImageCopyResampled($thumb,$tempimage,0,0,0,0,$thumbw,$thumbh,$width,$height);
ImageJPEG($thumb,$thname,95);
}
move_uploaded_file($thumb, $newthumbfile);
imagedestroy($tempimage);
?>