Up to $140 off-Lowest  Prices of 2024(Nov.21-Dec.2)

My Computer Tips

Home | About | Categories | All Tips & Tutorials

How to upload files larger than 2MB using PHP7

ID: 67

Category: PHP7

Added: 14th of January 2016

Views: 3,649



It seems my webhosting providers impose a 2MB limit on file uploads through PHP. It seems fair to me, but on the other hand if your running a website that requires your users to upload images, not all of them are going to understand the limits or understand how to reduce the size of the image to bring it under the 2MB limit.

Unless your webhosting provider gives you access to your own PHP configuration file, one solution is to override the PHP settings by creating an .htaccess file, which specifies the max filesize, and post max size.

If your using Linux create a new file on your desktop named .htaccess then copy paste the following code.

Save the file and upload this to your webspace. After this you should be able to upload files, images and other media larger than 2MB

php_value upload_max_filesize 12M
php_value post_max_size 12M
php_value max_execution_time 300
php_value max_input_time 300


I set the limit to 12MB which is suitable for my requirements, but can be set up to 64MB