First Option: Use this option in case you have permission to edit the php.ini file.
The upload_max_filesize and the post_max_size settings in the php.ini need to changed to support larger files than the php default allowed size.
set upload_max_filesize to the maximum size of file which need to be uploaded.
post_max_size should be set to greater than upload_max_filesize to handle the file and the size of form post variables part of file upload form.
In case multiple files are uploaded in the file upload form at a time, the post_max_size should be set to (upload_max_filesize * no of files)+ size of post variables.
upload_max_filesize=30M
post_max_size=31M
No need to update memory_limit and max_execution_time php settings, in case file is just moved using the move_uploaded_file to the final path in file upload php script.
But if the file upload script is processing the file or reading the file to a variable or doing any other processing which use memory and time etc, memory_limit and max_execution_time should be set.
Set memory_limit to amount of memory needed for the php script to run and max_execution_time to the time in seconds required to run the script.
memory_limit = 100M
max_execution_time = 120
Restart the webserver after the php.ini is changed for it to take effect.
Second Option: Use this option in case you do not have permission to update the global php.ini settings or to improve security.
Copy the upload php scripts to a new Child folder say "Upload" and create a file ".user.ini" in the new folder. Also make sure to update the file upload form action attribute to post to the new Script under the "Upload" Folder.
Add below settings to the newly created file. ".user.ini".
upload_max_filesize=30M
post_max_size=31M
;below are optional
memory_limit = 100M
max_execution_time = 120
"user_ini.filename" php.ini setting can updated to give the user setting file another name.
This option improves the security as the upload_max_filesize, post_max_size,memory_limit, max_execution_time are changed only for the
scripts in the new folder and will not impact php settings for scripts in other folders and prevents any unwanted resource utilization by bad scripts.
Please refer below links for more information on ".user.ini" settings
https://www.php.net/manual/en/configuration.changes.modes.php
https://www.php.net/manual/en/ini.list.php
https://www.php.net/manual/en/configuration.file.per-user.php
Restart the webserver for the new .user.ini changes to take effect.
Note:
The memory_limit and max_execution_time setting can also be set in the php upload script using ini_set and set_time_limit function instead of updating php.ini file .
If this option is used, not need to update the memory_limit and max_execution_time setting in the ini file.
Add below to the top of the php file upload script
ini_set('memory_limit', '100M');
set_time_limit(120);