From f940e4a0129ffeefd746c0ebdb25132413e388c0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Mon, 23 Apr 2012 13:23:20 +0200 Subject: [PATCH] display uploadable file size in media manager FS#2425 --- inc/lang/en/lang.php | 1 + inc/media.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 2ba220e64..c1fc543fb 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -99,6 +99,7 @@ $lang['searchmedia_in'] = 'Search in %s'; $lang['txt_upload'] = 'Select file to upload'; $lang['txt_filename'] = 'Upload as (optional)'; $lang['txt_overwrt'] = 'Overwrite existing file'; +$lang['maxuploadsize'] = 'Upload max. %s per file.'; $lang['lockedby'] = 'Currently locked by'; $lang['lockexpire'] = 'Lock expires at'; diff --git a/inc/media.php b/inc/media.php index 66984e957..841a5218e 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1602,7 +1602,35 @@ function media_uploadform($ns, $auth, $fullscreen = false){ echo NL.'<div id="mediamanager__uploader">'.NL; html_form('upload', $form); + echo '</div>'.NL; + + echo '<p class="maxsize">'; + printf($lang['maxuploadsize'],filesize_h(media_getuploadsize())); + echo '</p>'.NL; + +} + +/** + * Returns the size uploaded files may have + * + * This uses a conservative approach using the lowest number found + * in any of the limiting ini settings + * + * @returns int size in bytes + */ +function media_getuploadsize(){ + $okay = 0; + + $post = (int) php_to_byte(@ini_get('post_max_size')); + $suho = (int) php_to_byte(@ini_get('suhosin.post.max_value_length')); + $upld = (int) php_to_byte(@ini_get('upload_max_filesize')); + + if($post && ($post < $okay || $okay == 0)) $okay = $post; + if($suho && ($suho < $okay || $okay == 0)) $okay = $suho; + if($upld && ($upld < $okay || $okay == 0)) $okay = $upld; + + return $okay; } /** -- GitLab