...

View Full Version : fatal error: allowed memory prob



Chris-2k
10-13-2012, 03:09 AM
hi guys

im getting this prob:


Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 5372 bytes)

when uploading a big image, it's pointed to this func:

function create_thumb($image_file, $name, $thumbDir) {
$iDimension = getimagesize($image_file);
$type = $iDimension['mime'];
$custom_px = $_POST['maxdimensions'];

if ($type == "image/jpeg") { $tempThumb = imagecreatefromjpeg($image_file); }
elseif ($type == "image/bmp") { $tempThumb = imagecreatefromwbmp($image_file); }
elseif($type == "image/png") { $tempThumb = imagecreatefrompng($image_file); }
elseif ($type == "image/gif") { $tempThumb = imagecreatefromgif($image_file); }

$width = $iDimension[0]; // uploaded image width
$height = $iDimension[1]; // uploaded image height

$ratio = $width / $height; // calculate the ratio

if ($ratio > 1 ) {
$newW = $custom_px;
$newH = $custom_px / $ratio;
} else {
$newH = $custom_px;
$newW = $custom_px * $ratio;
}

$thumb = imagecreatetruecolor($newW, $newH);

//the resizing is going on here!
imagecopyresampled($thumb, $tempThumb, 0, 0, 0, 0, $newW, $newH, $width, $height);

//finally, save the image
imagejpeg($thumb, $thumbDir .'/thumb_' . $name);

// clean up
imagedestroy($thumb);
imagedestroy($tempThumb);
}

any help, thanks.

DrDOS
10-13-2012, 04:02 AM
The memory limit is set by the php.ini file, you can either increase the limit, not too likely unless it's your own server, or you can use a custom
php.ini file, or simply limit upload size to work within the assigned value.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum