In my previous post I discussed about .user.ini file and how it is useful in WAWS.
In today’s post I will address the issue of increasing the limit of the file size to a PHP site hosted on WAWS using the .user.ini file.
As mentioned in my previous post, we cannot edit the contents of the php.ini file as it is not permitted in WAWS. However we can add a .user.ini file and override certain settings.
One of the most common scenarios seen for PHP sites hosted on WAWS is to increase the limit of the file size that is permitted. The default setting defined in the PHP runtime (php.ini) is 2 MB. Since we cannot edit the php.ini we need to override this in .user.ini.
The PHP directive which governs the limit for the maximum file size that can be uploaded to WAWS is upload_max_filesize. It mode is PHP_INI_PERDIR as per List of php.ini directives and its default value is “2M” i.e., 2 MB. Below is a snapshot from PHP’s online documentation (List of php.ini directives).
So we know that we can override this setting in .user.ini file as it is allowed as per PHP documentation. So this is how we do it.
NOTE: If you are using custom PHP runtime as described here, then you have complete control over php.ini and can edit the corresponding sections and ignore this blog post.
Download and install FileZilla, Click here to download FileZilla. If the download link fails then please visit the FileZilla site to download the file: https://filezilla-project.org/download.php
Add a sample php page to your WAWS site with the following one line of code:
;Maximum size of the files that can be uploaded
upload_max_filesize = 16M
As seen in the above snippet, the upload_max_filesize directive is reading the values from the .user.ini file.
Thus, we have successfully overridden the PHP runtime settings.
Hope this helps. Until then CIAO!