最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - Wordpress upload file size error even after raising php limits

programmeradmin0浏览0评论

I get 'The uploaded file exceeds the uploadmaxfilesize directive in php.ini.' error while trying to upload a plugin which is just 5.1MB. I have raised the limits in php.ini file and also thru webmin.

This is my php.ini file

max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M

Here is my nginx.conf file. I have also increased clientmaxbody_size under server and http.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
client_max_body_size 24000M;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" "$http_x_forwarded_for"';

 access_log  /var/log/nginx/access.log  main;
 .........
 server_names_hash_bucket_size 128;
 server {
 client_max_body_size 24000M;
 server_name mydomain www.mydomain;
 .....

I get 'The uploaded file exceeds the uploadmaxfilesize directive in php.ini.' error while trying to upload a plugin which is just 5.1MB. I have raised the limits in php.ini file and also thru webmin.

This is my php.ini file

max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M

Here is my nginx.conf file. I have also increased clientmaxbody_size under server and http.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
client_max_body_size 24000M;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" "$http_x_forwarded_for"';

 access_log  /var/log/nginx/access.log  main;
 .........
 server_names_hash_bucket_size 128;
 server {
 client_max_body_size 24000M;
 server_name mydomain www.mydomain;
 .....
Share Improve this question asked Mar 16, 2018 at 18:05 aka_abaka_ab 11 bronze badge 6
  • if that is what the error says, then you must be making changes in the wrong place. At the very least you should find or write a utility that will let you debug that problm outside of wordpress (like a small php file handling upload in the old fashioned way) – Mark Kaplun Commented Mar 16, 2018 at 18:35
  • also check that it isn't being throttled in wp-config.php & restart the server after changing php config. – admcfajn Commented Mar 16, 2018 at 18:40
  • I tried uploading info.php and I was indeed editing the correct file. wp-config.php isn't being throttled. – aka_ab Commented Mar 16, 2018 at 18:45
  • phpinfo() will show you which config file is being used so you can edit the correct one. In my local environment, it is the fifth row of the info table output. – jdm2112 Commented Mar 16, 2018 at 18:56
  • I used the same command. I did edit the right php.ini – aka_ab Commented Mar 16, 2018 at 19:14
 |  Show 1 more comment

1 Answer 1

Reset to default 1

NOTE: You MUST reboot your server or reload your web server (Apache or Nginx) to ensure the changes take effect after each step.

You can first try to add the following to your theme's functions.php file. If it does not work, then remove it. If it does, I recommend you create a child theme so the code will remain active even after file changes during theme updates.

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

Second, you can try adding a php.ini file with the following contents to the root of the directory where your wordpress installation is. It is possible that Wordpress is not reading from the php.ini file located at the php directory.

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

The final thing you could try, if you want to change to apache web server rather than nginx is add the following to your .htaccess file

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

EDIT: You can attempt to add this to your wp-config.php file at the end:

define('WP_MEMORY_LIMIT', '64M');

/* That's all, stop editing! Happy blogging. */

Now do step one once more. Then clear your browser cache and try again.

发布评论

评论列表(0)

  1. 暂无评论