Now Reading
How To Increase File Upload Size Limit In PHP 7
Dark Light

How To Increase File Upload Size Limit In PHP 7

Avatar
high angle photography of cliff

This tutorial provides the steps to increase, decrease, or change the file upload size limit in PHP 7 for both Apache Web Server and NGINX Web Server. It provides the example code for Ubuntu 20.04 LTS and Windows 10. The steps should be the same on other versions of Windows, Ubuntu, and Linux systems. Prerequisites This tutorial assumes that you have access to an Ubuntu machine and Apache Web Server or NGINX Web Server, and PHP 7 are already installed on it. You may follow Install Ubuntu 20.04 LTS Desktop, Install Ubuntu 20.04 LTS On Windows Using VMware, and Spin Up Ubuntu 20.04 LTS Server On Amazon EC2 to install Ubuntu 20.04 LTS. You may also follow How To Install Apache 2 On Ubuntu 20.04 LTS and How To Install And Configure Nginx on Ubuntu 20.04 LTS. Apache Web Server We have to update the PHPs INI file to change the file upload size limit. Locate the php.ini file used by Apache Web Server according to your PHP installation and usage. I have provided a few examples as shown below. # WampServer -> Example -> /bin/php/php7.4.14/php.ini# XAMPP -> Example -> /php/php.ini# Ubuntu -> Apache Example -> /etc/php/7.4/apache2/php.ini# Ubuntu -> NGINX Example -> /etc/php/7.4/fpm/php.ini Now search your php.ini file for upload_max_filesize and post_max_size to update it as shown below. # file upload size limit; Maximum allowed size for uploaded files.; http://php.net/upload-max-filesize;upload_max_filesize = 2Mupload_max_filesize = 16# post request size limit; Maximum size of POST data that PHP will accept.; Its value may be 0 to disable the limit. It is ignored if POST data reading; is disabled through enable_post_data_reading.; http://php.net/post-max-size;post_max_size = 8Mpost_max_size = 16M After updating the maximum file size and post request size, restart the Apache Web Server to apply the changes. # Restart Apache Web Server – Ubuntusudo systemctl restart apache2 NGINX Web Server Locate the php.ini file used by NGINX Web Server according to your PHP installation and usage. I have provided the default location as shown below. # Ubuntu -> NGINX Example -> /etc/php/7.4/fpm/php.ini Now search your php.ini file for upload_max_filesize and post_max_size to update it as shown below. # file upload size limit; Maximum allowed size for uploaded files.; http://php.net/upload-max-filesize;upload_max_filesize = 2Mupload_max_filesize = 16# post request size limit; Maximum size of POST data that PHP will accept.; Its value may be 0 to disable the limit. It is ignored if POST data reading; is disabled through enable_post_data_reading.; http://php.net/post-max-size;post_max_size = 8Mpost_max_size = 16M After updating the maximum file size and post request size, restart the PHP FPM to apply the changes. # Restart PHP FPMsudo systemctl restart php7.4-fpm Summary This tutorial provided the required configurations to change or update the file upload size limit in PHP 7 for both Apache Web Server and NGINX Web Server. How To Install PHP For Nginx On Ubuntu 20.04 LTS

Touch The Stars

0 / 5

Your page rank:

What's Your Reaction?
Excited
0
Funny
0
In Love
0
Like It
0
Not Sure
0
View Comments (0)

Leave a Reply

Your email address will not be published.


Copyrights © 2021 Lucid.Hive.Systems. All Rights Reserved.