I am using Laravel as an API when I try to upload a file bigger than 2Mb I get error file failed to upload
. I saw that it's related to php.ini file, I tried updating post_max_size
and restart apache, but it didn't work. I don't know how to solve this error any help please.
CodePudding user response:
To increaes file upload size in PHP, you need to modify the upload_max_filesize
and post_max_size
values in your php.ini file.
upload_max_filesize = 10M
post_max_size = 10M
You can also do it via .htaccess file.
Use echo phpinfo();
to check you variable values.
Don't forget to restart your apache service after changes.
CodePudding user response:
Basically there are two php.ini files /etc/php/7.4/apache2/php.ini
that I was making changes to. But Laravel was using /etc/php/7.4/cli/php.ini
and I had to dd(php_ini_loaded_file());
which gives the path to the loaded php.ini file. After making changes to that file and restarting apache2 server the problem was solved.