Increase upload limit in WordPress – web shell

WordPress offers the possibility to upload images, videos and other file types in order to then embed or link them to the page. That’s nice. For example, I can improve my blog with useful images and screenshots. In general, however, it is important not to make images too large (file size). Otherwise the loading time suffers for the user. So only make images as large as necessary and then compress them (worth reading: Image CDN on keycdn.com). But what do you do when the file is too big for the file upload and WordPress refuses to upload it? Fortunately, there are solutions to increase the upload limit.

WordPress shows you the current upload limit when you want to upload a file. In this case the limit is 1 MB.

1. Increase WP_MEMORY_LIMIT

If you search the Internet with the problem, you will find it very quickly and the first tip you often read is an entry in your own wp-config.php to create a file.

In the wp-config.php there are different configurations for your WordPress installation. There you add the following entry: define('WP_MEMORY_LIMIT', '64M');

This entry sets the memory limit of WordPress to 64 MB. Now it’s best to check whether the upload limit has been adjusted and whether you can upload larger files. If it works, then the job is done here. If that doesn’t help, there is another point where you need to make a change.

2. Change limit in php.ini

Another tip that is often mentioned on the internet is: Upload limit in the php.ini change file.

WordPress runs on PHP and this php.ini contains various configuration directives on how PHP should behave on the server. Among other things, it also states how large a file that is uploaded can be (for professionals: we are talking about the maximum size of a POST request here, among other things).

How to change these values ​​in php.ini differs from host to host. Some offer a GUI for this, with which you can click through the various values ​​in the browser. If you have SSH access to your web space yourself, you can often change these values ​​directly in the file itself.

You should note the following values:

; Sicherstellen, dass der Upload eingeschaltet ist
file_uploads = On

; Memory Limit auf 128 MB erhöhen
memory_limit = 128M

; Maximale Dateigröße für Uploads
; Auf 64 MB setzen
upload_max_filesize = 64M

; Maximale Größe für POST Requests
post_max_size = 64M

(Lines beginning with a semicolon are comments)

Once the values ​​are set, you have to restart PHP (or restart the server) once so that the new configuration is loaded.

Info: Depending on the server configuration, the php.ini file is not reloaded and therefore the changes are not applied. Here you may have to restart the PHP FPM service separately.

Where is my php.ini?

The path to php.ini You can easily find out with the following command:

$ php -i | grep php.ini

# Output
# Configuration File (php.ini) Path => /package/host/localhost/php-7.0.3/lib
# Loaded Configuration File => /path/of/loaded/php.ini

INFO for shared hosting: If your website is on shared hosting, i.e. you do not have your own server but share one with several users, then it is often not possible to make these settings yourself. In this case, you simply have to write to your hoster directly.

3. Multisite setting

Last but not least, there is a third place where you can change the upload limit. This option is often not mentioned because it is only important for multisite installations.

As a network administrator, you can also increase the upload limit under Settings > Network settings. The point “Maximum file size of an upload” can be found under file upload settings and must also be adjusted. The value is calculated here in KB. So if we want a limit of 64 MB, enter 65536 KB ( 64 MB * 1024 = 65536 KB ).

In a multisite, the upload limit can be increased again separately in the network settings.  This option is rarely mentioned as a solution in forums, since it only affects multisites.In a multisite, the upload limit can be increased again separately in the network settings. This option is rarely mentioned as a solution in forums, since it only affects multisites.

summary

It is possible to increase the upload limit. In the best case, you only have to make the entry WP_MEMORY_LIMIT in the wp-config.php put. If that doesn’t help you have to go to the php.ini increase the file size for uploads and for multisites the entry in the network settings must also be increased.

If everything is configured correctly, you can also upload files up to 64 MB in the browser.If everything is configured correctly, you can also upload files up to 64 MB in the browser.

Previous post Increase WordPress upload limit
Next post Increase the WordPress upload limit