summaryrefslogtreecommitdiffstats
path: root/system/libraries/Upload.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-08-10 14:26:57 +0200
committerAndrey Andreev <narf@devilix.net>2016-08-10 14:26:57 +0200
commitc4bd43432df03e4f4835c7689c8ed722cd2c3020 (patch)
tree5603166833d78b0581bbe880adb53b6de085719d /system/libraries/Upload.php
parent488ad40ba334ca506f07bede97724726eac2b27f (diff)
parent9180a1264dc536c34e5cc8a0e44bb399a8ba484f (diff)
Merge branch '3.1-stable' into develop
Diffstat (limited to 'system/libraries/Upload.php')
-rw-r--r--system/libraries/Upload.php41
1 files changed, 14 insertions, 27 deletions
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 056f6de1e..a8cf75264 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -1086,13 +1086,7 @@ class CI_Upload {
if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
{
$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
-
- $memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', '');
-
+ $memory_limit = (int) ceil(filesize($file) + $memory_limit);
ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
}
@@ -1207,28 +1201,21 @@ class CI_Upload {
// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
- /* Fileinfo extension - most reliable method
- *
- * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the
- * more convenient FILEINFO_MIME_TYPE flag doesn't exist.
- */
- if (function_exists('finfo_file'))
+ // Fileinfo extension - most reliable method
+ $finfo = @finfo_open(FILEINFO_MIME);
+ if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
{
- $finfo = @finfo_open(FILEINFO_MIME);
- if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
+ $mime = @finfo_file($finfo, $file['tmp_name']);
+ finfo_close($finfo);
+
+ /* According to the comments section of the PHP manual page,
+ * it is possible that this function returns an empty string
+ * for some files (e.g. if they don't exist in the magic MIME database)
+ */
+ if (is_string($mime) && preg_match($regexp, $mime, $matches))
{
- $mime = @finfo_file($finfo, $file['tmp_name']);
- finfo_close($finfo);
-
- /* According to the comments section of the PHP manual page,
- * it is possible that this function returns an empty string
- * for some files (e.g. if they don't exist in the magic MIME database)
- */
- if (is_string($mime) && preg_match($regexp, $mime, $matches))
- {
- $this->file_type = $matches[1];
- return;
- }
+ $this->file_type = $matches[1];
+ return;
}
}