Mijn upload scriptje geeft bij sommige plaatjes deze error:
Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 17064 bytes) in /home/ticoma/domains/timothydevries.nl/public_html/plaatjes/iupload2.php on line 52
Ik zou denken dat hij dan bedoelt dat mijn plaatje te groot is, maar het plaatje is minder dan 175 kb klein, dus dat zou makkelijk moeten kunnen.
zou iemand hier een oplossing voor weten?
alvast bedankt
dit is mijn scriptje:
<h3>Uploaden</h3>
<?php
if(isset($_POST['uploaden'])){
if(is_uploaded_file($_FILES['plaatje']['tmp_name'])){
if($_FILES['plaatje']['type'] == "image/jpeg"){
$plaatje = imagecreatefromjpeg($_FILES['plaatje']['tmp_name']);
} elseif($_FILES['plaatje']['type'] == "image/png"){
$plaatje = imagecreatefrompng($_FILES['plaatje']['tmp_name']);
} elseif($_FILES['plaatje']['type'] == "image/gif"){
$plaatje = imagecreatefromgif($_FILES['plaatje']['tmp_name']);
} else{
echo'Error: Not supported filetype.';
$fout = 1;
}
if(!isset($fout)){
$formaat = getimagesize($_FILES['plaatje']['tmp_name']);
if($formaat[0] > 150 OR $formaat[1] > 150){
$welke = $formaat[0]/$formaat[1];
if($welke > 1){
$ratio = 150/$formaat[0];
} else{
$ratio = 150/$formaat[1];
}
} else{
$ratio = 1;
}
$breed = $formaat[0]*$ratio;
$hoog = $formaat[1]*$ratio;
$thumb = imagecreatetruecolor($breed,$hoog+16);
$tekstk = imagecolorallocate($thumb,255,255,255);
$achtergrondk = imagecolorallocate($thumb,0,0,0);
imagefill($thumb,0,$hoog+1,$achtergrondk);
imagecopyresized($thumb,$plaatje,0,0,0,0,$breed,$hoog,$formaat[0],$formaat[1]);
$tekst = 'Timothy';
imagestring($thumb,2,2,$hoog+1,$tekst,$tekstk);
$tijd = time();
mysql_query('INSERT INTO plaatjes (posterid, naam, tijd, geupload) VALUES('.$geg[id].',"'.$_FILES['plaatje']['name'].'",'.($tijd+2419199).','.$tijd.')');
$id = mysql_query('SELECT id FROM plaatjes WHERE posterid='.$geg[id].' AND naam="'.$_FILES['plaatje']['name'].'" AND tijd='.($tijd+2419199).' AND geupload='.$tijd);
$id = mysql_fetch_assoc($id);
imagejpeg($thumb, 'tumbs/'.$id[id].'.jpg');
imagedestroy($thumb);
if($formaat[0] > 800 OR $formaat[1] > 800){
if($welke > 1){
$ratio = 800/$formaat[0];
} else{
$ratio = 800/$formaat[1];
}
}
$ratio = $ratio/0.1875;
$breed = $formaat[0]*$ratio;
$hoog = $formaat[1]*$ratio;
$groot = imagecreatetruecolor($breed,$hoog+16);
$tekstk = imagecolorallocate($groot,255,255,255);
$achtergrondk = imagecolorallocate($groot,0,0,0);
imagefill($groot,0,$hoog+1,$achtergrondk);
imagecopyresized($groot,$plaatje,0,0,0,0,$breed,$hoog,$formaat[0],$formaat[1]);
$tekst = 'Timothy de Vries';
imagestring($groot,2,2,$hoog+1,$tekst,$tekstk);
imagejpeg($groot, 'plaatjes/'.$id[id].'.jpg');
imagedestroy($groot);
imagejpeg($plaatje, 'plaatje/'.$id[id].'.jpg');
imagedestroy($plaatje);
echo'Thumb: www.timothydevries.nl/plaatjes/thumb.php?id='.$id[id].'<br>';;
echo'Resized (max 800x800): www.timothydevries.nl/plaatjes/groot.php?id='.$id[id].'<br>';;
echo'Real format: www.timothydevries.nl/plaatjes/plaatje.php?id='.$id[id].'<br>';;
echo'<a href="index.php?pagina=ioverzicht">Back to my images</a>';
echo $_SESSION['gebruikersnaam'].$_SESSION['wachtwoord'];
} else{
echo'Error: Not suported file type.<br>Press <a href="index.php">here</a> to retry.';
}
} else{
echo'You didn\'t uploaded a file.<br>Press <a href="index.php">here</a> to retry.';
}
} else{
echo'You didn\'t uploaded a file.<br>Press <a href="index.php">here</a> to retry.';
}
?>
241 views