note 22119 added to features.file-upload

From: Date: Fri, 07 Jun 2002 11:39:50 +0000
Subject: note 22119 added to features.file-upload
Groups: php.notes 
Request: Send a blank email to php-notes+get-31557@lists.php.net to get a copy of this message
Hi, To get the max upload filesize i use this <?php echo get_max_upload(); function get_max_upload() { if (!ini_get("file_uploads")) { return FALSE; } $upload_max_filesize = get_real_size(ini_get("upload_max_filesize")); $post_max_size = get_real_size(ini_get("post_max_size")); // http://www.php.net/manual/en/features.file-upload.php User Contributed Notes - michaelpearl@mac.com $memory_limit = round(get_real_size(ini_get("memory_limit")) / 2); // http://www.php.net/manual/en/features.file-upload.php User Contributed Notes - NOmcartmelSPAM@NOmagianSPAM.com.au if ($upload_max_filesize>$post_max_size) { $max = $post_max_size; } else { $max = $upload_max_filesize; } if (($memory_limit!="")&&($memory_limit<$max)) { // i had problems to get the "memory_limit" from the php.ini (this is testing on winXP with apache) $max = $memory_limit; } return $max; } function get_real_size($size) { if ($size=="") { return 0; } $scan['MB'] = 1048576; $scan['M'] = 1048576; $scan['KB'] = 1024; $scan['K'] = 1024; while (list($key) = each($scan)) { if ((strlen($size)>strlen($key))&&(substr($size, strlen($size) - strlen($key))==$key)) { $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key]; break; } } return $size; } ?> -- http://www.php.net/manual/en/features.file-upload.php http://master.php.net/manage/user-notes.php?action=edit+22119 http://master.php.net/manage/user-notes.php?action=delete+22119 http://master.php.net/manage/user-notes.php?action=reject+22119

« previous php.notes (#31557) next »