How to change php file upload size limit in Ubuntu

Sometimes you will get maximum size file upload error on your LAMP setup. Because the maximum file size upload in php scripts which is set to 2Mb as default. This will also create the “No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration” error in phpmyadmin database import process.

To avoid these errors, your post_max_size and memory_limit need to be larger than upload_max_filesize.

To change php file upload limit in Ubuntu, please follow the below steps.

Open your terminal app and type below code and hit enter

sudo gedit /var/www/html/test.php

and type your ubuntu password if needed. It will open the test.php file in gedit.
Note: The default Apache2 web server document root is /var/www/html.
If you changed your default Apache2 web server document root to any other folder using this tutorial. then use below code

sudo gedit /home/manikandan/www/test.php

Type below code in the test.php file, save and exit it .

<?php phpinfo() ?>

Now open your favorite browser and type http://localhost/test.php in the address bar and press enter.

Also Read:  Pineapple Pictures Image Viewer

Find the “Loaded Configuration File” in your php info page and note download the path. Here its /etc/php/5.6/apache2/php.ini


Also search “upload_max_filesize” and note down the number. Here its 2M.

In your terminal, type the below code and hit enter. It will open the php.ini file in gedit text editor.

sudo gedit /etc/php/5.6/apache2/php.ini

Note: Here /etc/php/5.6/apache2/php.ini is loaded configuration php.ini file path. You can change it according to yours.

Find the upload_max_filesize in your php.ini file and change 2M to any higher value according to your need. Then save and exit it.

Restart Apache using below command

sudo service apache2 restart

Thats it.

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



Leave a Reply