Reputation: 793
Local machine is working 100% with every file size and my problem is on production server.
I still have no problem uploading files less than 2mb,
this error is only happening when i upload file more than 2mb.
i tried updating max file size in php.ini to 20M and restart nginx and php-fpm.
I've tried sudo nano /etc/nginx/nginx.conf
and added these:
http{
client_max_body_size 20M;
client_body_timeout 300s;
...
}
I've tried sudo nano /etc/php/7.2/fpm/php.ini
and changed these:
post_max_size = 20M
upload_max_filesize = 20M
I did restart my nginx and php like this:
sudo service nginx restart
sudo systemctl restart nginx
sudo service php7.2-fpm restart
But still less than 2mb file upload works and more than 2mb gives me error:
message: "The "" file does not exist or is not readable."
PS:
i also used sudo vim /etc/nginx/sites-enabled/mysite.com
and added client_max_body_size 20M;
before listen 80;
but still getting same error after restarting nginx and php7.2-fpm.
I printed phpInfo() and my post_max_size and upload_max_filesize are still 2 mb! I dont know why my phpInfo is not getting updated as well.
Upvotes: 1
Views: 1195
Reputation: 4330
I was struggling whit this and here is how I fixed it:
find which is my php.ini file
sudo find / -name php.ini
edit the file 2)
sudo vim /etc/php/7.4/cli/php.ini
edit filesizes 3) increase upload_max_filesize and post_max_size to whatever you need and save it
if you are using fpm
sudo service --status-all | grep -i fpm
This will give you the right service you are using
then
sudo service php7.4-fpm restart
then
sudo service nginx reload
Upvotes: 0
Reputation: 105
Try to set
client_max_body_size 20M;
inside the server
block in Nginx as well.
Upvotes: 1