Php 7 php.ini upload_max_filesize not working

I read a lot of solutions on the Internet, but cannot change the value of upload_max_filesize ( upload_max_filesize always = 2M)

here is my loaded php.ini in phpinfo() :

 Configuration File (php.ini) Path /etc/php/7.0/apache2 Loaded Configuration File /etc/php/7.0/apache2/php.ini Scan this dir for additional .ini files /etc/php/7.0/apache2/conf.d upload_max_filesize 2M 2M post_max_size 8M 8M 

here is my edited php.ini in /etc/php/7.0/apache2/php.ini

 ; http://php.net/post-max-size post_max_size = 86M ; http://php.net/upload-max-filesize upload_max_filesize = 40M 

im using ubuntu 14.04, apache2, php7.0 (I have reset apache2 many times after every change in php.ini)

+14
source share
11 answers

I apologized!

in my loaded php.ini configuration, my error_reporting values ​​are E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED → this is wrong !, so I changed it to

error_reporting: E_ALL , and then restart the apache2 server, now everything works fine!


so please note: if php.ini has any kind of error, it will use the default value (which means upload_max_filesize always 2M )

+8
source

I had another fix. os: ubuntu 16.04 phpversion: 7.0

I created a phpinfo.php file containing:

 <?php phpinfo() ?> 

put the phpinfo.php file in the root of your site www.mywebsite.com/phpinfo.php

Go to it and find the line:

Uploaded configuration file: /etc/php/7.0/cgi/php.ini

Now you know that the php.ini file is loading.

ssh to the server and use your favorite editing tool (mine is nano) to configure php.ini

change the values ​​according to your preference.

post_max_size = 128M

upload_max_filesize = 64M

Save and close the file.

Restart apache

 sudo service apache2 restart 

__

check phpinfo.ini if ​​new values ​​are set.

and if you have them, you must go.

+19
source

I had a fix for PHP-FPM 7.1

Change your php.ini in

/etc/php/7.1/fpm/php.ini

Make changes to any option you want: post_max_size, upload_max_filesize, max_execution_time, etc.

save and close the file.

run

sudo service php7.1-fpm restart

It will work!

+14
source

I also found that restarting the httpd service did not have /etc/php.ini changes to the loaded configuration file ( /etc/php.ini in Fedora 29). It is worth listing all the systemd modules and doing grep for the string "php":

 # systemctl list-unit-files | grep php php-fpm.service 

Restarting php-fpm helped me:

 # systemctl restart php-fpm 
+2
source

Most people forget to restart their php through the terminal, why it does not work, if you think that you did everything correctly, be sure to restart php & server.

+1
source

For php7.2-fpm

Ubuntu php-fpm is located in /etc/php/7.2/fpm , so

  1. cd /etc/php/7.2/fpm
  2. sudo nano php.ini
  3. Find post_max_size = 512M and add your favorite size that you really need
  4. Find upload_max_filesize = 512M and add your favorite size that you really need
  5. Save file
  6. Lastly, DO NOT FORGET TO RESTART PHP7.2-FPM to restart sudo service php7.2-fpm restart

That's all!

+1
source

Yes, actually I forgot to restart correctly.

restarting sudo apache2 service is not enough

first add the configurations to /etc/php/7.1/fpm/php.ini and /etc/php/7.1/cli/php.ini
# / php / - then your php version is here instead of "7.1". In fact, one of these configuration files is active (if you want to see what <?php phpinfo()?> in the indextest.php file and check it on the browser) Then change these settings for each file with what you want :

 post_max_size = 512M upload_max_filesize = 512M 

And then use the following command to restart the php server:

 sudo service php7.0-fpm restart #php<then your php version here> instead "7.0" 

or

 sudo /etc/init.d/php7.1-fpm restart #php<then your php version here> instead "7.1" 

Now you can see the changes in the size of the download. Hooray!

as shown here, you can learn more about php server controllers:

 $ sudo service php7.0-fpmstart # <- restart it $ sudo service php7.0-fpm stop # <- restart it $ sudo service php7.0-fpm restart # <- restart it $ sudo service php7.0-fpm reload # <- reload it 
0
source

I am using nginx and my solution was to restart php-fpm. Restarting nginx did nothing.

 sudo service php7.2-fpm restart 
0
source

After spending hours reading the forum, I decided this:

 cd /etc/php find . -name "*.ini" | xargs grep -il upload_max_filesize ./7.1/apache2/php.ini ./7.1/mods-available/better.ini ./7.1/cgi/php.ini ./7.1/cli/php.ini ./7.1/phpdbg/php.ini ./7.1/fpm/conf.d/20-better.ini ./7.1/fpm/php.ini ./7.1/embed/php.ini 

change upload_max_filesize to ./7.1/fpm/conf.d/20-better.ini then

 /etc/init.d/php7.1-fpm restart 

Now phpinfo reports: upload_max_filesize 10G 10G

Hope this helps.

0
source

I also had this problem!

if you use php-fpm service, you need to find php-fpm.conf and add the line

php_admin_value[upload_max_filesize] = 100M

to change another type of value

 #just for example php_flag[display_errors] = off php_admin_value[error_log] = /var/log/fpm-php.www.log php_admin_flag[log_errors] = on 
0
source

For those who have all the obvious settings mentioned in other answers and downloads of PHP files, still not working.

Check php.ini for open_basedir value. If set (which should be for security reasons), make sure that /tmp included in it. Or select a custom value in upload_tmp_dir and set open_basedir accordingly.

Then restart the FPM service.

0
source

All Articles