Symptom
You can upload files of a limited size through webmail or PHP, but if you try to attach a large file to an email or upload it to a website, you may encounter errors related to the file size. This is because PHP limits file uploads to a certain size by default, and you need to modify certain values to increase it.
Information:
Depending on the mode in which PHP is running on the website or webmail that is experiencing problems, you need to modify the corresponding php.ini. For example, if it is running under Apache, the path is probably /etc/php5/apache2/php.ini, and in the case of CGI it would be /etc/php5/cgi/php.ini.
Solution
The variables you need to modify to increase the limit are as follows:
upload_max_filesize = 2M
post_max_size = 8M- upload_max_filesize: Replace 2M with the desired maximum size in MB
- post_max_size: Replace 8M with the desired maximum size in MB + the size of the PHP form (e.g.: message text)
There are also other limits that affect the maximum attachment size PHP can handle, which you will need to review to ensure that the changes work correctly:
max_execution_time = 30
memory_limit = 64M- max_execution_time = 30: If you want to increase the upload limit in PHP, you will also need to increase this value depending on the maximum number of bytes set above
- memory_limit = 64M: You also need to increase this value because it controls the maximum memory a script can consume
Once you have made the changes, you need to restart the Cloud Server's web service. This can usually be done with the command:
# /etc/init.d/apache2 restartOr:
# /etc/init.d/httpd restartThe memory_limit variable must be greater than the post_max_size variable.
When making these changes, keep in mind that the post_max_size variable must be greater than upload_max_filesize.
Warning
Be careful when modifying these variables and do not specify very high limits, as this can quickly consume your server's resources.