PHP Upload Limit
Share Article To
Increase File Upload Size Limit in PHP-Apache, Changing File Upload Limits On Apache Server, phpinfo, upload_max_filesize, post_max_size, memory_limit

PHP Upload LimitAlmost for every developer and client it is headache to increase the file upload size on there site on Apache server. By default this value is 2MB. Means you can upload max 2MB size file at a time.

What is the value on your server check by following the below steps:
– Open ‘File Manager’ after login to cPanel
or
Open FileZilla and login to your host where you have your website files.
– Now in your favorite browser create and file with .php extension. File name can be anything.
– Add below code in this file.

<?php phpinfo(); ?>

– Upload this file on your website’s root directory.
– Now access this file through browser.
If the file name is phpinfo.php and your website link is http://mysite.com
then access this by http://mysite.com/phpinfo.php
– Now you can see your server configuration.
– In this web page search for upload_max_filesize and post_max_size the value is the

Now we will see what are the variables we should change to increase file upload size. There are three variables which are defined in php.ini file which is present under `/etc` directory in linux installation. These variables are as follows upload_max_filesize post_max_size and memory_limit

post_max_size value must be larger than upload_max_filesize and the memory_limit should be larger than post_max_size.
memory_limit > post_max_size > upload_max_filesize

WHY ?:
upload_max_filesize is the limit of any single file size user about to upload where as post_max_size is the limit of the entire body of the request, which could include multiple files. Let us see one simple example:

Given post_max_size = 40M and upload_max_filesize = 6M in this case you could upload up to 6 files of 6M each. But instead post_max_size = 6M and upload_max_filesize = 40M then you could only upload one 6M file before hitting post_max_size. It doesn’t help you to have upload_max_size > post_max_size.

Again the value set to memory_limit indicates the maximum amount of memory that a script is allowed to allocate.

A standard value for these three variables are as follows
128M > 64M > 32M :: memory_limit > post_max_size > upload_max_filesize

Note: You can change these value as per your convenience.

Leave a Reply

Your email address will not be published. Required fields are marked *