Increase PHP Upload File Size Limit



There are 3 directives that needs to be considered :

upload_max_filesize – The maximum size of an uploaded file
memory_limit – This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.
post_max_size – Sets max size of post data allowed. This setting also affects file upload

Upload Conditions :

post_max_size > upload_max_filesize
memory_limit > post_max_size

Method # 1: Edit php.ini (get php.ini path from the phpinfo function)
# vi /etc/php.ini

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

Then Restart Apache.

Method #2: Edit .htaccess
This method is used if the php.ini file cannot be found

Append / modify setting as follows:
php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M

If you are using Suhosin which was designed to protect your servers against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself. You need to edit /etc/php.d/suhosin.ini to set correct memory and upload limit. As long scripts are not running within safe_mode they are free to change the memory_limit to whatever value they want.




Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s