WordPress – How to change the Maximum Upload File Size

Out of the box, PHP defaults the Maximum Upload File Size to 2M. I.E 2M is the default setting.
Where 2M represents 2 Megabytes or 2048 Bytes  (1M = 1024 Bytes).

But what if we want to upload images that are larger than 2 Megabytes?
Well, to alter the Maximum Upload File Size in WordPress, you will need to change a setting in your php.ini file.

Where it says upload_max_filesize = 2M, you will need to alter the value of 2M.  Where 2M means 2 Megabytes or 2048 Bytes  (1M = 1024 Bytes).

So, let’s say that your or your client wants to be able to upload images that are just under 10MB. Then you would change this to 10M.

It is NOT a good idea to just make this some ridiculously large number. It’s there to protect the server from having to deal with large image uploads so please, put some thought into it.

So the Original Settings are…


; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M

After our changes, it becomes…


; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 10M

When you make any changes you will need to restart your webserver, for these changes to take effect!
This will depend on your OS and Webserver.

On Linux/Debian, for apache2, you can use the command


$ sudo systemctl reload apache2

On Linux/Debian, for NGINX, if you are using php7.4-fpm, you will need to restart PHP, for the changes to take effect.


$ sudo systemctl reload php7.4-fpm

BUT NGINX has a Default File Upload Size Restriction.

In NGINX, just changing the PHP upload_max_filesize setting is Not Enough as NGINX has it’s own setting for this. (See WordPress – The server cannot process the image. )

It is important to set the NGINX client_max_body_size to a value equal to or larger than the PHP upload_max_filesize setting.

 

Leave a Reply

Your email address will not be published.