dobrze działa tylko z plikami gif,
<?if(isset($_POST['DODAJ'])){
$nazwa = $_POST['nazwa'];
$f = $_FILES['zdj'];
if($f['type'] == 'image/bmp') $typ='bmp';
elseif($f['type'] == 'image/jpeg') $typ='jpeg';
elseif($f['type'] == 'image/png') $typ='png';
elseif ($f['type'] == 'image/gif') $typ='gif';
else $typ='Niepoprawny format obrazu.';
if($typ == 'jpeg') $img = imagecreatefromjpeg('../ftp2/galery/'.$f['name']);
elseif($typ == 'png') $img=imagecreatefrompng('../ftp2/galery/'.$f['name']);
elseif($typ == 'gif') $img=imagecreatefromgif('../ftp2/galery/'.$f['name']);
elseif($typ == 'bmp') $img=imagecreatefromwbmp('../ftp2/galery/'.$f['name']);
$x = imagesx($img);
$y = imagesy($img);
if($x > $y){
$nx = 100;
$ny = 100 * ($y / $x);
}elseif($x < $y){
$nx = 100 * ($x / $y);
$ny = 100;
}else{
$nx = 100;
$ny = 100;
}
$new_img = imagecreatetruecolor($nx, $ny);
imagecopyresampled($new_img, $img, 0, 0, 0, 0, $nx, $ny, $x, $y);
if($typ == 'jpeg') imagejpeg($new_img,'../ftp2/galery/male_'.$f['name']);
elseif($typ=='png') imagepng($new_img,'../ftp2/galery/male_'.$f['name']);
elseif($typ=='gif') imagegif($new_img,'../ftp2/galery/male_'.$f['name']);
elseif($typ=='bmp') imagewbmp($new_img,'../ftp2/galery/male_'.$f['name']);
}
}
$zdj=$f['name'];
$zdj=$zdj;
$new_img="male_".$f['name'];
$sql="INSERT INTO galeria SET fotka1='$zdj',minfotka='$new_img',id_kategorii='$nazwa' ";
echo 'Dodano zdjecie: '.$zdj. 'miniaturka:'.$new_img; } ?>