简体   繁体   中英

php ini setting upload_max_filesize not working

I need to change upload limit to 2GB on php 7.2 Ubuntu 16.04.

As a first step, when I check /etc/php/7.2 folder I can see cli and fpm folders.

So to make sure the ini location I have print the php info using

 echo phpinfo()

And I got the output

Server API                         :   FPM/FastCGI
Virtual Directory Support          :   disabled
Configuration File (php.ini) Path  :   /etc/php/7.2/fpm
Loaded Configuration File          :   /etc/php/7.2/fpm/php.ini 

And I have edited /etc/php/7.2/fpm/php.ini with

upload_max_filesize = 2048M

And restarted the apache but using phpinfo() still it print

  upload_max_filesize   2M

So I have tried with command php -i | grep -i "loaded configuration file" php -i | grep -i "loaded configuration file" but it print different configuration file,

 Loaded Configuration File => /etc/php/7.2/cli/php.ini

On this file also I have changed upload_max_filesize to 2048 and restarted the Apache and still the result is same.

What could be the problem, any help will appreciated.

I got the problem resolved by the answer here Changes to upload_max_filesize in Ubuntu php.ini will not take effect .

Instead of restarting the apache I have to restart the php using

sudo service php7.2-fpm restart

first at all you should remove all older php version on your ubuntu. what is your cli php version? are you sure that you find correctly php.ini location? please run this command " locate php.ini "

您还应该在 php.ini 中更改:post_max_size=2Gb

Sometimes due to error in php.ini files the configuration files are not loaded after that specific error line. In that case you have to thoroughly check the php.ini file and fix the errors.

Alternatively you can download fresh php.ini files for your php version and replace your existing file with the new one.

After making changes in the new file restart your server using service apache2 restart .

If changing /etc/php/7.2/fpm/php.ini and /etc/php/7.2/cli/php.ini still does not work out, try changing /etc/php/7.2/apache2/php.ini . Please note that you might have to restart the apache2 server using sudo service apache2 restart . (This solution is tested on server with Ubuntu installed. )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM