Get the File Uploading Limit – Max File Size Allowed to Upload

PHP file upload max size is determined by 2 configuration values in php.ini, namely upload_max_filesize and post_max_size. You can get the maximum file size allowed in uploading by this snippet:

$max_upload = (int)(ini_get('upload_max_filesize'));
$max_post = (int)(ini_get('post_max_size'));
$upload_mb = $max_upload <= $max_post ? $max_upload : $max_post;

Wherein $upload_mb is the maximum file size allowed for upload in MB. Just display this value beside the file upload control so the user knows the limit.

Author: Yang Yang

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: