Support / KnowledgeBase

 
Search the KnowledgeBase Search

How do I increase the PHP upload limits?

  • Applies to: All DV, Grid

  • Difficulty: Medium

  • Time needed: 10 minutes

  • Tools needed: Root, vi knowledge

 
  • Applies to: All DV
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: SSH, root access, vi knowledge
  • Applies to: All Grid
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: SSH, root access, vi knowledge

(mt) Media Temple makes a concerted effort to ensure the accuracy of this content. However, if you discover any issues, please open a support request via the (mt) AccountCenter.

The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please consult our Statement of Support for further information.

Symptom

I am unable to upload larger files with PHP scripts.

You are able to upload small files via PHP, but larger uploads fail. Or, you receive an error message like "Allowed memory size of 103809024 bytes exhausted (tried to allocate 0 bytes)".

Solution

PHP has several configuration options to limit resources consumed by scripts. By default, PHP is set to allow uploads of files with a size of 2MB or less.

Try increasing the following values in your php.ini file, for example:


memory_limit = 99M
max_execution_time = 300
upload_max_filesize = 20M
post_max_size = 24M

On the Grid, once you make those changes and save the file, that's all you need to do. The Apache web server doesn't need to be restarted (and, to be clear, you don't have that level of access on the Grid platform).

If you're unsure how to modify your php.ini, please click here for detailed instructions.

Additional information

If the upload_max_filesize is larger than post_max_size, you must increase post_max_size so that it is bigger than upload_max_size.

If the value of post_max_size is larger than memory_limit, you must increase memory_limit so that it is larger than post_max_size.

Resources

READ ME FIRST

This article has been mirrored from the Parallels Knowledge Base as a courtesy to our DV server customers. As they are the authoritative source of the information covered in this topic we encourage you to check their original article since this content is subject to change.

(mt) Media Temple makes a concerted effort to ensure the accuracy of this content. However, if you discover any issues, please open a support request via the (mt) AccountCenter.

The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please consult our Statement of Support for further information.

Symptom

I am unable to send attachments via webmail or upload big files with PHP scripts.

You are able to upload small files in webmail or with a PHP script, but larger files cannot be uploaded or you get "The page cannot be displayed" error when you push the "Send Message" button. If error reporting is enabled, you receive the "Allowed memory size of 8388608 bytes exhausted (tried to allocate 0 bytes)" or "Request Entity Too Large" error.

Solution

PHP has several configuration options to limit resources consumed by scripts. By default, PHP is set to allow uploads of files with a size of 2MB or less.

Try increasing the following values in /etc/php.ini, for example:


memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M

Save the file, then restart Apache.

/etc/init.d/httpd restart

Additional information

If the upload_max_filesize is larger than post_max_size, you must increase post_max_size so that it is bigger than upload_max_size.

If the value of post_max_size is larger than memory_limit, you must increase memory_limit so that it is larger than post_max_size.

Resources

 

Continue