"Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes)".
This is the error i get but I am only trying to upload a 1mb image. I have increased the memory limit in php.ini and the execution time. I am trying this on a local MAMP server, on a Mac using firefox. This going to be for an online image gallery. Any ideas? Below is the code:
ini_set("memory_limit","30M");
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "images/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
//below here for the removed code
$save = "thumbs/uploads/" . $imagepath; //This is the new file you saving
$file = "images/" . $imagepath; //This is the original file
$imagesize = getimagesize($file);
list($width, $height) = $imagesize;
unset($imagesize);
if($width>$height)
{
$modwidth = 150;
$diff = $width / $modwidth;
$modheight = $height / $diff;
}else{
$modheight = 150;
$diff = $height / $modheight;
$modwidth = $width / $diff;
}
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($file);
$imagecopy = imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagedestroy($image);
imagedestroy($im);
imagedestroy($imagecopy);
imagedestroy($source);
$imagejpg = imagejpeg($tn, $save, 100);
imagedestroy($tn);
imagedestroy($imagejpg);
EDIT
This has now been sorted out hopefully. One of my colleagues had a solution all along but neglected to tell me!