Gäller det för GD1 eller GD2?
Postar lite kod från ett av mina uppladdningsskript:
// Ladda upp ny bild
if ($_POST['fil'] == Ja){
$mapp = "../thumbs/";
$mapp2 = "../foton/";
// Ta bort STORA bokstäver
$_FILES["file"]["name"] = strtolower($_FILES["file"]["name"]);
// Ta bort mellanslag
$_FILES["file"]["name"] = str_replace(' ', '_', $_FILES["file"]["name"]);
// Ta bort å
$_FILES["file"]["name"] = str_replace('å', 'a', $_FILES["file"]["name"]);
// Ta bort ä
$_FILES["file"]["name"] = str_replace('ä', 'a', $_FILES["file"]["name"]);
// Ta bort ö
$_FILES["file"]["name"] = str_replace('ö', 'o', $_FILES["file"]["name"]);
if (file_exists($mapp.$_FILES['file']['name'])) {
header("location: galleri.php?Uppladdad=Kopia");
exit;
}
if(!empty($_FILES['file']['name'])) {
$file = $_FILES['file'];
$storlek = getimagesize($_FILES['file']['tmp_name']);
$nybredd = 90;
$nyhojd = 90;
$nybredd2 = 600;
$nyhojd2 = 600;
// kolla filändelsen
$filandelse = explode('.',$file['name']);
$sort = count($filandelse) - 1;
$so = $filandelse[$sort];
// Allowed filetypes
if ($so != 'jpg'){
// Fel filtyp
header("location: galleri.php?Uppladdad=Nej");
exit;
}
// skapa tumnagel
if (($storlek[0] - $nybredd) >= ($storlek[1] - $nyhojd)) {
$bildbredd = $nyhojd;
$bildhojd = ($nybredd/$storlek[0])*$storlek[1];
} else {
$bildhojd = $nyhojd;
$bildbredd = ($bildhojd/$storlek[1])*$storlek[0];
}
$bild_kalla = imagecreatefromjpeg($file['tmp_name']);
// GD2
$bild_skapa = imagecreatetruecolor($bildbredd, $bildhojd);
imagecopyresampled ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
// GD1
//$bild_skapa = imagecreate($bildbredd, $bildhojd);
//imagecopyresized ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
imagejpeg ($bild_skapa, $mapp.$file['name'], 100);
imagedestroy ($bild_skapa);
// skapa stor bild
if (($storlek[0] - $nybredd2) >= ($storlek[1] - $nyhojd2)) {
$bildbredd = $nyhojd2;
$bildhojd = ($nybredd2/$storlek[0])*$storlek[1];
} else {
$bildhojd = $nyhojd2;
$bildbredd = ($bildhojd/$storlek[1])*$storlek[0];
}
$bild_kalla = imagecreatefromjpeg($file['tmp_name']);
// GD2
$bild_skapa = imagecreatetruecolor($bildbredd, $bildhojd);
imagecopyresampled ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
// GD1
//$bild_skapa = imagecreate($bildbredd, $bildhojd);
//imagecopyresized ($bild_skapa, $bild_kalla, 0, 0, 0, 0, $bildbredd, $bildhojd, $storlek[0], $storlek[1]);
imagejpeg ($bild_skapa, $mapp2.$file['name'], 100);
imagedestroy ($bild_skapa);
header("Location: galleri.php?Uppladdad=Ja");
exit;
}
}
?>