No to OK. To teraz mam coś takiego:
<?php
function img_resize($img_path,$dest_path,$max_width,$max_height)
{
$img_width = $img_size[0];
$img_height = $img_size[1];
$new_width = $max_width;#
$new_height = $max_height;#
$zrd = ImageCreateFromJpeg($img_path);
$prz = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResized($prz,$zrd,0,0,0,0,$new_width,$new_height,$img_width,$img_height);
ImageJpeg($prz, $dest_path, 80);
ImageDestroy($zrd);
ImageDestroy($prz);
####
$background = imagecreatefromjpeg($dest_path);
$insert = imagecreatefrompng(\"bg.png\");
imagecolortransparent($insert,imagecolorexact($insert,0,255,30));
$insert_x = imagesx($insert);
$insert_y = imagesy($insert);
imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100);
imagejpeg($background,\"\",100);
####
}
}
function img_big($img_path,$dest_path) {
$img_width = $img_size[0];
$img_height = $img_size[1];
$new_width = $max_width;
$new_height = $max_height;
$zrd = ImageCreateFromJpeg($img_path);
$prz = ImageCreateTrueColor($img_width,$img_height);
ImageCopyResized($prz,$zrd,0,0,0,0,$img_width,$img_height,$img_width,$img_height);
ImageJpeg($prz, $dest_path, 80);
ImageDestroy($zrd);
ImageDestroy($prz);
}
}
##################
$file_path = $_FILES['file']['tmp_name'];
$file_name = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$file_error = $_FILES['file']['error'];
$error_msg=\" \";
if($file_error>0){
switch($file_error)
{
case 1: $error_msg.=\"- Za duży plik.<br>\";
case 2: $error_msg.=\"- Za duży plik.<br>\";
case 3: $error_msg.=\"- Plik niedoszedł w całości (spróbuj ponownie).<br>\";
case 4: $error_msg.=\"- Nie wysłałeś żadnego pliku.<br>\";
}
}else{
if($file_size>10){
if($file_type==\"image/pjpeg\" || $file_type==\"image/jpeg\"){
$foto_id = '1';
$dest_path = \"./upload/\". $foto_id . \".jpg\";
$resized = img_big($file_path,$dest_path);
$dest_path = \"upload/mini/\". $foto_id . \".jpg\";
$resized = img_resize($file_path,$dest_path,80,80);
}else{
$error_msg.=\"- Plik niezostał załadowany.<br>\";
}
}else{
$error_msg.=\"- Zły typ pliku (tylko JPEGi).<br>\";
}
}else{
$error_msg.=\"- Niewysłałeś żadnego pliku.<br>\";
}
}else{
$error_msg.=\"- Niewysłałeś żadnego pliku.<br>\";
}
}
$msg = \"<span class=gold_s>Wystąpiły błędy:</span><br>\" . $error_msg;
}else{
$msg = \"Co by niebyło, Fotka dodana.\";
}
?>
Problem w tym, że to mi na stronie wyświetla pełno "krzaczków", a obrazka nie nakłada na miniaturkę.