From 69d069ce520ac696ee7bd1ec57d97dd1c4e3202f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 1 Aug 2010 01:33:42 +0000 Subject: [PATCH] #619434 by jim0203, jablko: Fixed can't set 'default maximum file size per upload' when upload_max_filesize() is '0' (unlimited). --- includes/file.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/file.inc b/includes/file.inc index 9fbecfed015..34cb472b295 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1784,9 +1784,15 @@ function file_upload_max_size() { static $max_size = -1; if ($max_size < 0) { + // Start with post_max_size. + $max_size = parse_size(ini_get('post_max_size')); + + // If upload_max_size is less, then reduce. Except if upload_max_size is + // zero, which indicates no limit. $upload_max = parse_size(ini_get('upload_max_filesize')); - $post_max = parse_size(ini_get('post_max_size')); - $max_size = ($upload_max < $post_max) ? $upload_max : $post_max; + if ($upload_max > 0 && $upload_max < $max_size) { + $max_size = $upload_max; + } } return $max_size; }