Welcome Guest, Not a member yet? Register   Sign In
CI 2.0 upload library: memory_limit
#1

[eluser]Bas Vermeulen[/eluser]
I have a question about the do_xss_clean() function of the upload library. This function starts with checking the current memory limit, adds the file size and updates the memory limit with the new value (old value + file size).

File: system/libraries/Upload.php (@ bitbucket)
Code:
if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '')
        {
            $current = ini_get('memory_limit') * 1024 * 1024;

            // There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
            // into scientific notation.  number_format() ensures this number is an integer
            // http://bugs.php.net/bug.php?id=43053

            $new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');

            ini_set('memory_limit', $new_memory); // When an integer is used, the value is measured in bytes. - PHP.net
        }

My memory_limit is set @ 256mb,which should be much more then enough. But this script doesn't check if their is enough, it always adds the file size and tries to update the memory_limit. Ofc we set a max value, so for every upload our server returns an error: ALERT - script tried to increase memory_limit to 268480769 bytes which is above the allowed value.

This is kinda annoying, can someone explain why this function works like this? Is it a bug or is there a special reason for doing it like this?

Thanks in advance for your thoughts!


Messages In This Thread
CI 2.0 upload library: memory_limit - by El Forum - 12-01-2010, 08:48 AM
CI 2.0 upload library: memory_limit - by El Forum - 12-01-2010, 10:45 AM
CI 2.0 upload library: memory_limit - by El Forum - 12-01-2010, 11:09 AM
CI 2.0 upload library: memory_limit - by El Forum - 12-01-2010, 11:47 AM
CI 2.0 upload library: memory_limit - by El Forum - 12-02-2010, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB