WordPress Upload Media Limit to 2MB

Issue:

WordPress defaults upload limit to 2MB causing upload fail

Environment:

WordPress on Docker with Nginx

Resolution:

Increase WordPress upload file size to 8MB. To check what is the current max upload size limit in your WordPress site then navigate to WP Admin -> Media -> Add New.

Step 1) Locate .htaccess file in root folder

Step 2) Edit with your favorite editor and insert below four lines of code after ifModule
php_value upload_max_filesize 8M
php_value post_max_size 8M
php_value max_execution_time 300
php_value max_input_time 300

Step 3) Save .htaccess file and refresh media upload screen to see the new upload limit

If you still have problem upload, refer to increase Nginx client max body size here

WordPress Media Upload Error on Docker with Nginx

Issue:

HTTP error message displayed when upload media on WordPress as shown below

or

Error message found in nginx error log:
[error] 71#71: *164 client intended to send too large body: 1524386 bytes

Environment:

WordPress on Docker with Nginx

Resolution:

increase upload size by adding below syntax to nginx.conf:

client_max_body_size 8M;

Step-by-step instructions:-

Step 1) copy original nginx.conf file from nginx container with Docker command

docker cp 98fd0d924718:/etc/nginx/nginx.conf .

Note: replace 98fd0d924718 with your nginx container id

Step 2) open nginx.conf file and add client_max_body_size 8M; between “http {“ and before “log_format”

http {
     include /etc/nginx/mime.types;
     default_type application/octet-stream;
     client_max_body_size 8M;
     log_format main ‘$remote_addr - $remote_user [$time_local] “$request” ‘

Step 3) copy modified nginx.conf file back to nginx container

docker cp nginx.conf 98fd0d924718:/etc/nginx/nginx.conf

Step 4) enter nginx container to restart nginx service

docker exec -it 98fd0d924718 /bin/bash
service nginx reload

Step 5) try to upload again. If you want to increase the size of upload file more than default 2MB, follow this instruction.

Reference:

http://wiki.nginx.org/HttpCoreModule#client_max_body_size