
The steps are as follows:
The command above will print the path to the php.ini file that your server is using, in my case I got:
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini
Before now, you might have been editing /etc/php/7.2/apache2/php.ini thinking that would solve the problem but no, it does not!
Now run: $ sudo nano /etc/php/7.2/cli/php.ini
Our concern is the values of post_max_size
, upload_max_filesize
and memory_limit
which by default has the value of 8M
, 2M
, and 128M
respectively. Now you see why you could not upload more than 2MB sized file .
Next up, search for those variables and change their values to suit your need. While doing that, ensure that the sizes follow the same ratio as the default values, that is memory_limit
should be greater followed by post_max_size
and then upload_max_filesize
. For example, in my case, I used the following values:
post_max_size = 6G
upload_max_filesize = 4G
memory_limit = 8G
Once you’re done changing the values to suit your need, save the changes with CTL Xthen type Y and hit ENTER.
Next up, restart apache: $ sudo /etc/init.d/apache2 restart
NOte - this work for apache server if are running the nginx
then
$ sudo cp /etc/php.ini.default /etc/php.ini
Edit the values as stated above
brew services restart php@7.2 [ replace 7.2 with the version of php you’re using]
That is it! Now you can upload large files within the range of the values you specified above without troubles .