...

View Full Version : handleSize func not working



Chris-2k
10-13-2012, 03:13 PM
hi

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


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($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE);

$data = curl_exec($ch);
$size = curl_getinfo($ch, CURLINFO_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)

Fou-Lu
10-13-2012, 06:41 PM
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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum