> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setting the PHP maximum upload file size

> Learn to increase PHP upload limits with upload_max_filesize and post_max_size in php.ini.

This article describes how to change the maximum upload file size for PHP scripts by using the **upload\_max\_filesize** and **post\_max\_size** php directives.

## 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.

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
```

<Tip>
  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](/docs/view-php-settings).
</Tip>

## Setting the directives

The preferred way to set PHP directives is using the graphical tools in the control panel:

* For accounts using the cPanel control panel, see [this article](/docs/changing-php-versions-and-settings-in-cpanel).
* For accounts using the Plesk control panel, see [this article](/docs/switching-php-versions-on-plesk).

Many accounts also allow the use of a custom php.ini file.  For instructions to create a custom php.ini file, see [this article](/docs/custom-php-ini-files).

## More information

* To view a complete list of *php.ini* directives, please visit [http://www.php.net/manual/en/ini.list.php](http://www.php.net/manual/en/ini.list.php).

* For more information about the **upload\_max\_filesize** directive, please visit [http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize](http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize).

* For more information about the **post\_max\_size** directive, please visit [http://www.php.net/manual/en/ini.core.php#ini.post-max-size](http://www.php.net/manual/en/ini.core.php#ini.post-max-size).

## Related articles

* [Changing PHP versions and settings using PHP Selector](/docs/changing-php-versions-and-settings-in-cpanel)

* [Custom php.ini files](/docs/custom-php-ini-files)

* [Using php.ini directives](/docs/using-php-ini-directives)

* [Switching PHP versions on Plesk](/docs/switching-php-versions-on-plesk)
