diff options
author | Andrey Andreev <narf@devilix.net> | 2016-08-22 12:19:49 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2016-08-22 12:19:49 +0200 |
commit | d9c1100a489969c4012057eeeaa6a9de6d250a43 (patch) | |
tree | 4f5b56c8759ccd2f2561a936956b7bf238b0e925 /system | |
parent | 121ff9c43650ec383015fe3719d6a9c5c980081f (diff) | |
parent | c95df51c90dc9506ec9a37a43d87238965210550 (diff) |
Merge branch '3.1-stable' into develop
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Upload.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index a8cf75264..23fd02ead 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1083,10 +1083,27 @@ class CI_Upload { return FALSE; } - if (memory_get_usage() && ($memory_limit = ini_get('memory_limit'))) + if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')) > 0) { - $memory_limit *= 1024 * 1024; - $memory_limit = (int) ceil(filesize($file) + $memory_limit); + $memory_limit = str_split($memory_limit, strspn($memory_limit, '1234567890')); + if ( ! empty($memory_limit[1])) + { + switch ($memory_limit[1][0]) + { + case 'g': + case 'G': + $memory_limit[0] *= 1024 * 1024 * 1024; + break; + case 'm': + case 'M': + $memory_limit[0] *= 1024 * 1024; + break; + default: + break; + } + } + + $memory_limit = (int) ceil(filesize($file) + $memory_limit[0]); ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net } |