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
- 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 ? - Edit the file using below command
Sudo vi path_of_php.ini
Example:
php configuration file using phpinfo() in info.php
sudo vi /Applications/XAMPP/xamppfiles/etc/php.ini
then search for variable upload_max_size and post_max_size
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
post_max_size=40m
upload_max_size=40m
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 ?