Hiho, ich habe folgendes Problem: beim untenstehenden Script bekomme ich immer die Meldung das das Format nicht unterstützt wird. Hat vielleicht einer eine Idee woran es liegt?
Code:
function UploadImage2(){
global $userinfo;
$file = $_FILES['objUpload2'];
if(exif_imagetype($file['tmp_name']) == 1 || exif_imagetype($file['tmp_name']) == 2 || exif_imagetype($file['tmp_name']) == 3){
if (is_uploaded_file($file['tmp_name'])){
switch (exif_imagetype($file['tmp_name'])){
case 1:
//GIF
$img = imagecreatefromgif($file['tmp_name']);
break;
case 2:
//JPG
$img = imagecreatefromjpeg($file['tmp_name']);
break;
case 3:
//PNG
$img = imagecreatefrompng($file['tmp_name']);
break;
default:
break;
}
list($width, $height, $ctype) = getimagesize($file["tmp_name"]);
$xscale=$width/500;
$yscale=$height/500;
if ($yscale>$xscale){
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
}
else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}
$imgResized = imagecreatetruecolor($new_width, $new_height);
$transparent = imagecolorat($img, 0,0);
imagefill($imgResized, 0, 0, $transparent);
imagecolortransparent($imgResized, $transparent);
imagecopyresampled($imgResized, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
switch (exif_imagetype($file['tmp_name'])){
case 1:
//GIF
$file_name = "".$userinfo["vorname"]."_".$userinfo["name"]."_2.gif" ;
$img = imagegif($imgResized , "uploads/".$file_name);
break;
case 2:
//JPG
$file_name = "".$userinfo["vorname"]."_".$userinfo["name"]."_2.jpg" ;
$img = imagejpeg($imgResized , "uploads/".$file_name);
break;
case 3:
//PNG
$file_name = "".$userinfo["vorname"]."_".$userinfo["name"]."_2.png" ;
$img = imagepng($imgResized , "uploads/".$file_name);
break;
}
return $file_name;
}
else{
echo "An error occured when trying to create the temp image.";
}
}
else{
echo "This format is not supported. Only .gif, .jpg and .png are accepted.";
}
}