If you’ve got a web application that uploads files to the server through a PHP script, you might have noticed that by default you can’t upload terribly large files. Here’s how to change it.

The reason the limit is set fairly low by default is for stability and security reasons – a malicious script or attacker could attempt to DoS your server with large file uploads and temporarily shut your application down.

To change the values you’ll need to edit your php.ini file, normally found at this file path:


Here are the settings you want to change:

This setting controls the size of an HTTP post, and it needs to be set larger than the upload_max_filesize setting.

This value sets the maximum size of an upload file.


You’ll want to make sure your script memory limit is set to a decent size, probably larger than either of the other two settings.

Setting the Variables

You can set the values by using a numeric value followed by M for the amount of MB you want to allocate for each variable. For instance, to allow 20MB files to be uploaded, you’d use something like this:

memory_limit = 64M
upload_max_filesize = 20M
post_max_size = 25M

You’ll need to restart your Apache server once you’ve made this change, with this command:

/etc/init.d/httpd restart

Setting the Upload Size Per Application

You can make this setting change for a specific web application by putting it into the .htaccess file instead, in the directory of the application. Note that this will only work if your server has enabled overrides for your virtual host or server.

For instance, you could put the following into the file:

php_value memory_limit = 64M
php_value upload_max_filesize = 20M
php_value post_max_size = 25M

Once you save the file, the changes should be applied.

Profile Photo for Lowell Heddings Lowell Heddings
Lowell is the founder and CEO of How-To Geek. Heโ€™s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work.
Read Full Bio ยป

The above article may contain affiliate links, which help support How-To Geek.