From 316ebf78a3fdecac4021928a1b206c72eceaca60 Mon Sep 17 00:00:00 2001 From: moodler Date: Tue, 2 Dec 2003 14:34:24 +0000 Subject: [PATCH] Take post_max_size into account when calculating maximum sizes. --- lib/moodlelib.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e92d406961..98cfe6a4dd 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1096,14 +1096,15 @@ function valid_uploaded_file($newfile) { function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=0) { /// Returns the maximum size for uploading files -/// There are six possible upload limits: +/// There are seven possible upload limits: /// /// 1) in Apache using LimitRequestBody (no way of checking or changing this) /// 2) in php.ini for 'upload_max_filesize' (can not be changed inside PHP) /// 3) in .htaccess for 'upload_max_filesize' (can not be changed inside PHP) -/// 4) by the Moodle admin in $CFG->maxbytes -/// 5) by the teacher in the current course $course->maxbytes -/// 6) by the teacher for the current module, eg $assignment->maxbytes +/// 4) in php.ini for 'post_max_size' (can not be changed inside PHP) +/// 5) by the Moodle admin in $CFG->maxbytes +/// 6) by the teacher in the current course $course->maxbytes +/// 7) by the teacher for the current module, eg $assignment->maxbytes /// /// These last two are passed to this function as arguments (in bytes). /// Anything defined as 0 is ignored. @@ -1114,6 +1115,13 @@ function get_max_upload_file_size($sitebytes=0, $coursebytes=0, $modulebytes=0) } $minimumsize = get_real_size($filesize); + if ($postsize = ini_get("post_max_size")) { + $postsize = get_real_size($postsize); + if ($postsize < $minimumsize) { + $minimumsize = $postsize; + } + } + if ($sitebytes and $sitebytes < $minimumsize) { $minimumsize = $sitebytes; } -- 2.39.5