Increasing the Upload Limit in PHP

By default, the upload limit in PHP is set to 2MB. This is often insufficient, especially when we want to attach large-scale databases, we have problems because of this problem.

So how do we change the upload limits? First you need to have access to the server or at least be able to edit the php.ini file. If you have a server, you can refer to this article to find the php.ini file, I explained what is needed there. But to put it briefly;

php -i | grep 'Configuration File'

For example, when I ran this command, it gave me the path /etc/php.ini. So let's open it for editing.

nano /etc/php.ini

We need to edit the upload_max_filesize and post_max_size settings. For example, for the 200MB upload limit, we should write:

upload_max_filesize = 200M
post_max_size = 200M

By the way, make sure that the upload_max_filesize value is not more than the post_max_size value.

Make these settings and close your file. And all you have to do is restart the server. Since I am using apache on a Centos machine, the command I use is;

systemctl restart httpd.service

Now you can use a code like this in php to check the limits;

echo ini_get('upload_max_filesize');
echo ini_get('post_max_size');

good work.


There are no comments, make the firs comment