How to change the maximum upload file size for PHP scripts
This article describes how to change the maximum upload file size for PHP scripts by using the upload_max_filesize and post_max_size directives in a php.ini file.
The information in this article only applies to certain types of hosting accounts. To determine whether or not the information below applies to your account, please see this article
This article assumes that you have already set up a custom php.ini
file on your web site. If you have not already set up a custom php.ini
file, please read this article
Changing the maximum upload file size
By default, the maximum upload file size for PHP scripts is set to 128 megabytes. However, you may want to change these limits. For example, you can set a lower limit to prevent users from uploading large files to your site. To do this, change the upload_max_filesize and post_max_size directives in your php.ini file.
To ensure that file uploads work correctly, the post_max_size directive should be a little larger than the upload_max_filesize. For example, the following settings demonstrate how to set a file upload limit to 20 megabytes:
upload_max_filesize = 20M
post_max_size = 21M
To verify the current value of the upload_max_filesize
directive and other directives, you can use the phpinfo()
function. For more information, please see this article
- Custom php.ini files
You can use php.ini files to customize a wide range of PHP settings for your web site. Learn how here.
- Using php.ini directives
The directives in php.ini files allow you to control many settings for your web site. For example, you can control error logging, specify time zone information, and more.