Sometimes, a client or whoever is in charge may ask you, the developer, that they want a few things to change about the site. It could be that they have an additional task for you. Maybe a bug no one noticed until now has reared it's ugly head and now you have to fix it. Or maybe they want to upload a file, but it's not going through, because your site's saying that the file's too large. What's a developer to do? In this case, you have a few options.

 

php.ini

The easiest way to change these settings would be to update your core php settings with the “php.ini” file. This way, php settings will be applied to the whole server using the same php version. The first thing to do would likely be to ask your web host to change the setting for you, as they should probably know if any changes are being made to the server. However, if you have access to the server's files and are allowed permission to update php configurations, you can update the upload limit by finding and updating the following parameters:

memory_limit = 32M

post_max_size = 8M

upload_max_filesize = 2M

Note the way the settings are ordered. It's because a lower limit on a related setting carries greater weight than a higher setting. A good rule of thumb would be to think of it like this: memory_limit > post_max_size > upload_max_filesize. Setting upload_max_filesize to 8MB would be useless if the post_max_size is 2MB, which would limit the size of the request, rendering it impossible to upload any file larger than 2MB since that is all requests are limited to.

This would be useful if you have access to multiple sites being hosted on the same server, and would like the same setting to be applied to all of them, granted they are using the same php version and php.ini configuration file. However, if for any reason you are not able to access the php.ini file or this solution is not preferred, there are other methods.

 

.htaccess

Another way to do it would be through updating your site's “.htaccess” file in Drupal's root directory, as the .htaccess file will be used to set configurations per directory. You can change the setting using code like so:

php_value memory_limit 32M

php_value post_max_size 8M

php_value upload_max_filesize 2M

An advantage of this is that settings on “.htaccess” will only be applied to the current site the file is located in. This could be useful on say, a shared hosting environment. You probably will not be able to access the server's main configurations since the server is sharing resources with other sites being hosted, rendering php.ini an unreachable solution.

However, a big thing to note for this solution, is that it is only applied to PHP if it is being run as an Apache module. Other modules like FastCGI do not make use of .htaccess, which makes this an unlikely solution.

 

PHP info()

After using any of the above solutions, it's time to check if any of them actually worked. Drupal's status report page ( /admin/reports/status ) includes a link next to the PHP version that allows admins to check PHP settings under two columns: one for Master Values (which are defined inside the php.ini file) and Local Values (defined in either .htaccess or settings.php files). Note that local values supersede master values, meaning if that values under the local values column match the values that you set, the change has successfully taken effect.