From 23dabbe986d8885753c3bfcfc1f0614b02844601 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 13 May 2005 23:20:22 +0000 Subject: [PATCH] Added fetch_max_attachment_size() --- functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/functions.php b/functions.php index 87f2300..08bb48d 100644 --- a/functions.php +++ b/functions.php @@ -421,6 +421,30 @@ class Functions { return strval(end(explode('.', $filename))); } + + /** + * Gets the maximum file size for attachment uploading, as specified by PHP. If no value is present, 10 MB (represented in bytes) is returned + * + * @return int The maximum file upload size in bytes + */ + function fetch_max_attachment_size() + { + if ($size = @ini_get('upload_max_filesize')) + { + if (preg_match('#[^0-9].#', $size)) + { + return $size; + } + else + { + return intval($size) * 1048576; + } + } + else + { + return 10 * 1048576; + } + } } /*=====================================================================*\ -- 2.43.5