upload billede til mysql thumb
hej exp'erkan man ikke lavet et script som laver et thumb billede og derefter ligger man det ned i database lige som med store billeder
har prøvet men viker ikke:
------------------ kode --------------------
$maxWidth = "300";
$maxHeight = "300";
$src_thumb = $_FILES['img_billede']['tmp_name'];
list($width,$height) = getimagesize($_FILES['img_billede']['tmp_name']);
if ($width>$maxWidth || $height>$maxHeight) {
$scrRatio = $width/$height;
$distRatio = $maxWidth/$maxHeight;
if ($distRatio>$scrRatio) {
$newHeight = $maxHeight;
$newWidth = round($maxHeight*$scrRatio);
} else {
$newHeight = round($maxWidth/$scrRatio);
$newWidth = $maxWidth;
}
} else {
$newWidth=$width;
$newHeight=$height;
}
$thumb = imagecreatetruecolor($newWidth, $newHeight);
if ($imageType == "image/pjpeg") {
$source = imagecreatefromjpeg($src_thumb);
} elseif ($imageType == "image/x-png") {
$source = imagecreatefrompng($src_thumb);
} elseif ($imageType == "image/gif") {
$source = imagecreatefromgif($src_thumb);
}
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if ($imageType == "image/pjpeg") {
header('Content-type: image/jpeg');
$thumb_billede = imagejpeg($thumb);
} elseif ($imageType == "image/x-png") {
$thumb_billede = imagepng($thumb);
} elseif ($imageType == "image/gif") {
$thumb_billede = imagegif($thumb);
}
