summaryrefslogtreecommitdiffstats
path: root/system/libraries/Upload.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-08-22 12:18:36 +0200
committerAndrey Andreev <narf@devilix.net>2016-08-22 12:18:36 +0200
commit549a601bac3b1467168e0bb7b5642ba7fc59c35e (patch)
treecf93e74fcd642f213514549329bc8168b5fe1320 /system/libraries/Upload.php
parent1927709235ed11f51b700abcb390b660e2762053 (diff)
Fix CI_Upload errors on PHP 7.1
Diffstat (limited to 'system/libraries/Upload.php')
-rw-r--r--system/libraries/Upload.php23
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
}