How to Increase Upload File Size Limit PHP in Ubuntu?

By Hardik Savani May 14, 2024 Category : PHP Installation Ubuntu

i Developer,

In this tutorial, I will show you php increase upload file size limit ubuntu apache. It's a simple example of how to increase file size limit in php. This example will help you how to increase max file size in php.ini ubuntu. I explained simply step by step ubuntu php increase file upload size.

When i was working on my php project and i need to direct import mysql database in my phpmyadmin in Ubuntu 14.04 system, but my database size was 30MB, so i can't upload my database. that's why I need to change upload max file in php.ini. so try to find something how to change upload_max_filesize in php apache2. So if you also fetch problem like this then you can solve that issue just following example:

You can use this command with your ubuntu 22.10, ubuntu 22.04, ubuntu 21.10, ubuntu 21.04, ubuntu 20.04, ubuntu 18.04 and ubuntu 16.04 server.

You need to follow the below steps:

Find PHP Configuration File Location:

Here, you need to run the following command to get the currently loaded php.ini file in your ubuntu system.

php -i | grep php.ini

You will find the following output and copy the loaded php.ini file path:

Configuration File (php.ini) Path => /etc/php/8.1/cli

Loaded Configuration File => /etc/php/8.1/cli/php.ini

Update php.ini File:

Here, you need to run the following command to open the php.ini file and update it using the nano command:

sudo nano /etc/php/8.1/cli/php.ini

Next, the php.ini file will open, find the following variable, and update the value:

post_max_size = 100M

upload_max_filesize = 100M

max_file_uploads = 20

max_input_vars = 200

memory_limit = -1

Then save it.

Restart Apache Server:

Next, restart your apache server using the following command:

sudo service apache2 restart

Now, you can check it.

I will work.

I hope it can help you...

Tags :