Warning: imagedestroy() expects parameter 1 to be resource, integer given in... on line 55
dodatkowo nie zawsze dodaje mi obrazek z rozszerzeniem .jpg
a tu kod:
<?php { $allowed = array ('image/pjpeg', 'image/JPEG', 'image/JPG', 'image/jpeg', 'image/jpg', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif'); { $url='../rsah/upload/'; $turl='../rsah/thumb/'; $tmpName=$_FILES['userfile']['tmp_name']; $name=$_FILES['userfile']['name']; //do miniaturek switch($sType) { case IMAGETYPE_GIF: $gType=imagecreatefromgif($tmpName); break; case IMAGETYPE_PNG: $gType=imagecreatefrompng($tmpName); break; case IMAGETYPE_JPEG: $gType=imagecreatefromjpeg($tmpName); break; default: } $sourceRatio=$sWidth/$sHeight; $thumbnailRatio=$maxWidth/$maxHeight; if($sWidth<=$maxWidth && $sHeight<=$maxHeight) { $tWidth=$sWidth; $tHeight=$sHeight; } else if ($thumbnailRatio>$sourceRatio) { $tWidth= (int) ($maxHeight * $sourceRatio); $tHeight= $maxHeight; } else { $tWidth= $maxWidth; $tHeight= (int) ($maxWidth/$sourceRatio); } $thumbnailImage=imagecreatetruecolor($tWidth,$tHeight); imagecopyresampled($thumbnailImage,$gType,0,0,0,0,$tWidth,$tHeight,$sWidth,$sHeight); imagejpeg($thumbnailImage,$turl.$name,90); imagedestroy($sType); imagedestroy($thumbnailImage); } else { } } else { } ?>