Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    handleSize func not working

    hi

    can any1 tell me why my func isn't working:

    PHP Code:
        function verifyImage($files, array $aConfig) {
            if(
    handleSize($files) > configMaxSize($aConfig['max_filesize'])) 
            {
                
    trigger_error('Error: the file size is too big, '$aConfig['max_filesize'] .' is the max filesize');
            }
            
            return 
    $sResult;
        }

        function 
    handleSize($files)
        {
            if(
    isalocalFile($files)) 
            {
                
    // It's a local file.
                
    $size filesize($files);
            } 
            else 
            {
                
    // It's remote file.
                 
    $ch curl_init($files);
            
                 
    curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
                 
    curl_setopt($chCURLOPT_HEADERTRUE);
                 
    curl_setopt($chCURLOPT_NOBODYTRUE);
            
                 
    $data curl_exec($ch);
                 
    $size curl_getinfo($chCURLINFO_CONTENT_LENGTH_DOWNLOAD);
            
                 
    curl_close($ch);
            }
            return 
    $size;
        } 
    i know it's not working as im getting:
    Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 5372 bytes)

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You've simply run out of memory. Increase the size from 12MB in the php.ini. I'm not sure why that's set so low, even older versions of PHP were like 20MB, the current is 128MB.
    You can also stream whatever you need. I don't see anything in this code in particular that would get anywhere near 12MB of data, so I'd suspect you have open resources that haven't been destroyed (such as GD images).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •