PHP Upload File Size Limit
There are few different ways for PHP Upload File Size Limit setup. And its depending on server and control panel it differs. Lets see one by one. I will discuss here my known possible ways. And if you have any other possible solution. Just write a comment with its detail on next page.
I Prefer to start with Ubuntu Apache Localhost or direct VPS or VPN. You might installed direct Apache PHP and MySQL means quite simple. We can change the php.ini file to take effect. If you installed LAMP or any other Apache related programs like control panel. We can do it through either php.ini or user.ini or through htaccess file.
1. Apache localhost Ubuntu
/etc/php5/apache2/. For PHP 5 version
/etc/php/7.1/fpm For PHP 7 version and nginx
/etc/php/7.1/Apache For PHP 7 and Apache
You can see
php.ini file. Just open it on your favourite text editor and find these lines.
; Maximum allowed size for uploaded files. upload_max_filesize = 2M ; Must be greater than or equal to upload_max_filesize post_max_size = 2M
And change the values
; Maximum allowed size for uploaded files. upload_max_filesize = 512M ; Must be greater than or equal to upload_max_filesize post_max_size = 512M
There after you need to restart Apache server
sudo service apache2 restart
The newer version of cpanel has UI to make changes for the upload size. It’s quite easy and simple to do. Just goto your cpanel and Select PHP Versions. There you can see the
Switch to PHP options.
Than now you can see php.ini configurations. I think it’s last one from the given list of options. Just change the
upload_max_filesize to 512 MB.Then click Apply and save it. Now it will take few seconds to reflect. But it will work for you.
3. Other Control Panel Programs
If you are using older cpanel and other control panel software’s. You have to do it through custom
This is alternative method. Some shared hosting servers they don’t allow us to moderate the default php.ini files. But we can create one inside the current shared hosting directory or root of our access on shared hosting create and copy paste the below code in it.
; Maximum allowed size for uploaded files.
upload_max_filesize = 512M
; Must be greater than or equal to upload_max_filesize
post_max_size = 512M
It will reflect immediately. But in some cases it will take sometime to reflect there.
This is quite similar to previous one. But you need to do it if the previous one failed to change the size. Just rename the
This one of a popular way to do it. But you have to be very careful while working with it. If you messup anything. The whole site may get changes and it results badly.
Just append this code to your
.htaccess file. It will take care of file size.
<IfModule> php_value upload_max_filesize 512M php_value post_max_size 512M </IfModule>
There is another way we can do it. That’s more conveninent and easier to do. Just open the root or main file of your work or it might be the configuration file for every framework or project. And add this line very beginining to it.
ini_set('post_max_size', '512M'); ini_set('upload_max_filesize', '512M');
6. Other Cpanel Programs
Some other programs for cpanel is different. Thats you can check with hosting provider to get the functionality, may be you can understand with my above proposed methods.
The PHP Upload File Size Limit can be changed with above methods and if you face any challenges or issues you can comment it on next tab
comments tab, I will help you to fix it.