PHP Image Uploader - Hitting memory limit?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalthar
Forum Newbie
Posts: 7
Joined: Fri Dec 11, 2009 2:28 pm

PHP Image Uploader - Hitting memory limit?

Post by kalthar »

Hey folks

I have a bit of an annoying problem with PHP, an image uploader (that we have been using for some time now) and it has been highly reliable up to this point.

I uploaded 31 images and all the names are written into the database, however when the script completed the images had not been uploaded and image name data had not been written into the database, I tried again using only 1 image, then 10 and finally 20, all of these worked, which makes me think it's a memory limit or post_max_size issue, however I tried increasing post_max_size to 64M and it still didn't work, our memory limit is set at 256M by default.

Any help would be greatly appreciated

Code Exerpt

Code: Select all

 
while(list($key,$value) = each($_FILES['images']['name'])) {
    array_push($imageNameArray, $_FILES['images']['name'][$key]);
    if(!empty($value))
            {
                $filename = $value;
                    $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
 
                    $add = realpath(SITEBASE."/".PROMOIMAGES."/".$filename);
                    
                    copy($_FILES['images']['tmp_name'][$key], $add);
                    chmod("$add",0777);
            }
    }
 
    // CREATE SQL FOR INSERT IMAGES INTO DATABASE
    $imageSql = "";
    foreach ($imageNameArray as $key => $val){
        $imageSql .= str_replace(" ","_",$val).";";
    }
}else{
    $imageSql = ""; // THERE ARE NO IMAGES
}
 
Post Reply