Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-13-2012, 02:09 AM   PM User | #1
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
fatal error: allowed memory prob

hi guys

im getting this prob:
Code:
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:
PHP Code:
    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 ) {
            
$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$tempThumb0000$newW$newH$width$height);
    
        
//finally, save the image
        
imagejpeg($thumb$thumbDir .'/thumb_' $name);
        
        
// clean up
        
imagedestroy($thumb);
        
imagedestroy($tempThumb);
    } 
any help, thanks.
Chris-2k is offline   Reply With Quote
Old 10-13-2012, 03:02 AM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,146
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
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.
DrDOS is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:50 AM.


Advertisement
Log in to turn off these ads.