Spread the love

Php is the most used language in web. sometimes it required to upload the files which is greater then 2 mb.

In php default upload size is 2 mb and if we wanted to increase it then we have multiple ways to change the size of uploading.

1. Change from php.ini file

php.ini is main configuration file in php where all settings of php are defined. This type of configuration mainly used on localhost or dedicated server where we can access file system using ssh terminal.

Steps to change the upload size

  1. Locate/Find the php.ini file

    Sometimes we install multiple version of php in our system and it will get hard to find the correct file for php.ini. so to find the php.ini we can follow this guideline. Easiest way to find php.ini ?
  2. Edit the file using below command

    Sudo vi path_of_php.ini


    php configuration file using phpinfo() in info.php
This image has an empty alt attribute; its file name is Screenshot-2021-08-24-at-8.35.49-AM-1024x586.png

sudo vi /Applications/XAMPP/xamppfiles/etc/php.ini

then search for variable upload_max_size and post_max_size

upload_max_size in php.ini
post_max_size in php.ini

and then restart the apache server

sudo service apache2 restart

2. Create php.ini file in root of project

if you are on shared server then you can create own php.ini file on root of project and add below code


then save the file

3. Create .htaccess file and set php ini variables

Same as php.ini on root of project we can also add php configuration in htaccess file

php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 200
php_value max_input_time 200

then save .htaccess file in root of your project

4. Update from cpanel of website

To edit the configuration from cpanel you can follow this guideline. Easiest way to find php.ini ?

Leave a Reply