Skip to content

upload_max_filesize vs post_max_size: upload bigger files to WordPress

· The AYT team · 5 min read

Man typing on a laptop at a wooden table, with a phone and notebook beside it

upload_max_filesize is the maximum size of a single uploaded file, and post_max_size is the maximum size of the whole request a form sends (all files plus the other fields). To upload a 100 MB file to WordPress, both must be above 100 MB, with post_max_size at least as large as upload_max_filesize. You change them in your host's PHP settings editor or in a .user.ini file.

What upload_max_filesize and post_max_size limit

Setting What it limits PHP default What WordPress shows when it's exceeded
upload_max_filesize one file 2M "The uploaded file exceeds the upload_max_filesize directive in php.ini."
post_max_size the whole request (files and fields) 8M "The link you followed has expired" or an HTTP error when uploading media
max_file_uploads the number of files in one request 20 files above the limit are ignored
max_execution_time / max_input_time running time and time to receive the data depends on the server the upload stops for large files on slow connections

The defaults are the ones in the PHP documentation. Hosts almost always change them, so check what you actually have, not what the manual says.

When a request exceeds post_max_size, PHP empties $_POST and $_FILES completely. WordPress receives an empty form with no security code, which is where the confusing expired-link message comes from, as explained in the guide to "The link you followed has expired".

How to set them so they work together

The rule in the PHP documentation: post_max_size must be larger than upload_max_filesize, and memory_limit should generally be larger than post_max_size. A set that works for files up to 128 MB:

upload_max_filesize = 128M
post_max_size = 130M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300

Write the unit as a single letter: 128M, not 128MB. PHP only understands K, M and G.

Don't set values far above what you actually upload. The site's public forms (contact, comments) use the same limits, and a limit of several gigabytes lets anyone send huge requests.

Check the current values

In wp-admin, under Tools → Site Health → Info → Server, you'll find Upload max filesize and PHP post max size, along with PHP time limit and PHP memory limit. The Media → Add Media File page shows the effective limit below the upload area, which is the smaller of the two.

Where to change them

Both settings are PHP_INI_PERDIR: they can be set in the server configuration or per folder, but not from code. That rules out ini_set() in functions.php or wp-config.php, which simply has no effect.

  1. The PHP settings (php.ini) editor in your hosting panel. The recommended route: the panel knows where the server reads the values.
  2. A .user.ini file in the site's main folder, on servers running PHP-FPM. Add the lines above and wait a few minutes: PHP rereads the file periodically (every 5 minutes by default).
  3. php.ini, if you have access to the server configuration (a VPS or your own server). Restart PHP-FPM after the change.
  4. .htaccess with php_value, only on Apache with PHP as a module. On PHP-FPM it causes a 500 error, and nginx doesn't read it.

Some plugins promise to "increase the upload limit" from wp-admin. They can only change what the server allows, so they don't replace the steps above.

The panel's PHP settings editor: upload_max_filesize, post_max_size and memory_limit

The web server's limit

Before it reaches PHP, the request goes through the web server, which has its own limit:

  • nginx: client_max_body_size, 1 MB by default. Exceeding it returns 413 Request Entity Too Large before WordPress ever sees the request;
  • Apache: LimitRequestBody.

If you raised the PHP limits and get a 413, the web server's limit needs changing too. On shared hosting your host sets it.

Very large files: go around the form

For archives of hundreds of megabytes (backups, videos, catalogues), the wp-admin form is the wrong tool. Upload the file over FTP or through the File Manager straight into wp-content/uploads/. To make it show up in the media library you need one more step: WP-CLI (wp media import) or a plugin that registers files already on the server. Videos are usually better hosted on a video platform and embedded in the page.

Frequently asked questions

Why does Media → Add Media File still show the old limit?

Either the change hasn't been read yet (.user.ini is reread periodically), or you wrote it somewhere the server doesn't use. Site Health shows the real values.

Do I need to raise memory_limit too?

Not for the upload itself, but it helps afterwards: generating thumbnails for large images uses a lot of memory. See how to increase the WordPress memory limit.

On AYT hosting

In the AYT panel, the PHP settings (php.ini) page has fields for upload_max_filesize, post_max_size, max_execution_time and memory_limit, separately for each domain, and PHP limits and workers shows the account's PHP limits. The web server is nginx, so php_value lines in .htaccess don't apply, and its upload limit follows your PHP values (up to 1024 MB), so there is nothing separate to change for a 413 error. You can also upload large files through the File Manager or FTPS accounts. See the plans on the WordPress hosting page.

More articles

All articles