PHP beginner |
|
Hallo,
edit
Ik heb anders gemaakt namelijk:
<?php
if(isset($_GET['cat_titel']))
{
$cattie = $_GET['cat_titel'];
if(isset($_POST['uploaden']))
{
$cattie = $_GET['cat_titel'];
echo $cattie;
$dir = "fotos/". $cattie ."/";
$thumb_dir = "fotos/".$cattie."/thumbs/";
$maxsize = 100000;
$max_y = 100;
$max_x = 100;
$pathinfo = pathinfo($_FILES['bestand']['name']);
$ext = $pathinfo["extension"];
switch($ext)
{
case "jpg" : $thumb = imagecreatefromjpeg($_FILES['bestand']['tmp_name']);
break;
case "jpeg" : $thumb = imagecreatefromjpeg($_FILES['bestand']['tmp_name']);
break;
case "gif" : $thumb = imagecreatefromgif($_FILES['bestand']['tmp_name']);
break;
case "png" : $thumb = imagecreatefrompng($_FILES['bestand']['tmp_name']);
break;
default : $wrongext = 1;
}
if(isset($wrongext))
{
$error = "Verkeerde Extensie";
}
else
{
if($_FILES['bestand']['size'] > $maxsize)
{
$error = "Bestand is te groot";
}
else
{
$succes = true;
}
}
if(!isset($succes) || isset($error))
{
echo "<b>Er is een fout op getreden:</b><br>";
echo $error;
imagedestroy($thumb);
}
else
{
move_uploaded_file($_FILES['bestand']['tmp_name'], $dir.$_FILES['bestand']['name']) or die("Kan niet uploaden");
$x = imagesx($thumb);
$y = imagesy($thumb);
if(($max_x/$max_y) < ($x/$y))
{
$eind = imagecreatetruecolor($x/($x/$max_x), $y/($x/$max_x)) or die("Fout: imagecreattreucolor() 1");
}
else
{
$eind = imagecreatetruecolor($x/($y/$max_y), $y/($y/$max_y)) or die("Fout: imagecreattreucolor() 2");
}
imagecopyresized($eind, $thumb, 0, 0, 0, 0, imagesx($eind), imagesy($eind), $x, $y) or die("Fout: imagecopyresized()");
imagegif($eind, $thumb_dir.$_FILES['bestand']['name']) or die("Fout: imagegif()");
imagedestroy($thumb);
imagedestroy($eind);
echo "<a href=\"".$dir.$_FILES['bestand']['name']."\" target=\"_blank\"><img src=\"".$thumb_dir.$_FILES['bestand']['name']."\" border=\"0\"></a>";
}
}
else
{
?>
<form name="form1" method="post" action="">
<input type="file" name="bestand">
<input name="uploaden" type="submit" id="uploaden" value="Uploaden">
</form>
<?php
}
}
else
{
echo "Kies een categorie:<BR>";
$query_cat = mysql_query("SELECT * FROM categorie");
while($a = mysql_fetch_assoc($query_cat))
{
echo "<a href='index.php?pagina=plaatje&plaat=toevoegen&cat_titel=".$a['titel']."'>".$a['titel']."</a>";
}
}
?>
<?php if(isset($_GET['cat_titel'])) { $cattie = $_GET['cat_titel']; if(isset($_POST['uploaden'])) { $cattie = $_GET['cat_titel']; $dir = "fotos/". $cattie ."/"; $thumb_dir = "fotos/".$cattie."/thumbs/"; $maxsize = 100000; $max_y = 100; $max_x = 100; $pathinfo = pathinfo($_FILES['bestand']['name']); $ext = $pathinfo["extension"]; switch($ext) { case "jpg" : $thumb = imagecreatefromjpeg($_FILES['bestand']['tmp_name']); break; case "jpeg" : $thumb = imagecreatefromjpeg($_FILES['bestand']['tmp_name']); break; case "gif" : $thumb = imagecreatefromgif($_FILES['bestand']['tmp_name']); break; case "png" : $thumb = imagecreatefrompng($_FILES['bestand']['tmp_name']); break; default : $wrongext = 1; } { $error = "Verkeerde Extensie"; } else { if($_FILES['bestand']['size'] > $maxsize) { $error = "Bestand is te groot"; } else { $succes = true; } } { echo "<b>Er is een fout op getreden:</b><br>"; imagedestroy($thumb); } else { move_uploaded_file($_FILES['bestand']['tmp_name'], $dir.$_FILES['bestand']['name']) or die("Kan niet uploaden"); $x = imagesx($thumb); $y = imagesy($thumb); if(($max_x/$max_y) < ($x/$y)) { $eind = imagecreatetruecolor ($x/($x/$max_x), $y/($x/$max_x)) or die("Fout: imagecreattreucolor() 1"); } else { $eind = imagecreatetruecolor ($x/($y/$max_y), $y/($y/$max_y)) or die("Fout: imagecreattreucolor() 2"); } imagecopyresized ($eind, $thumb, 0, 0, 0, 0, imagesx ($eind), imagesy ($eind), $x, $y) or die("Fout: imagecopyresized()"); imagegif ($eind, $thumb_dir.$_FILES['bestand']['name']) or die("Fout: imagegif()"); imagedestroy($thumb); imagedestroy($eind); echo "<a href=\"".$dir.$_FILES['bestand']['name']."\" target=\"_blank\"><img src=\"".$thumb_dir.$_FILES['bestand']['name']."\" border=\"0\"></a>"; } } else { ?> <form name="form1" method="post" action=""> <input type="file" name="bestand"> <input name="uploaden" type="submit" id="uploaden" value="Uploaden"> </form> <?php } } else { echo "Kies een categorie:<BR>"; { echo "<a href='index.php?pagina=plaatje&plaat=toevoegen&cat_titel=".$a['titel']."'>".$a['titel']."</a>"; } } ?>
Maar nu krijg ik een foutmelding namelijk:
Verkeerde Extensie
Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/virtualweb.nl/koipaleis/koipaleis/admin/plaatje.php on line 78
terwijl het gewoon een .gif of .jpg is?
|