How to change the maximum upload file size

Every time you try and upload a file, do you receive an error claiming that the file exceeds the maximum size allowed? If so, you need to increase the size. 

Run the following command in terminal and look for Loaded Configuration File

php --ini

You need to set the value of the upload_max_filesize and post_max_size directives in your php.ini

upload_max_filesize restricts the maximum size of each individual file
post_max_size limits the total size of all uploaded files in a single request

To upload large files, the post_max_size value must be larger than upload_max_filesize

; Maximum allowed size for uploaded files.
upload_max_filesize = 50M

; Must be greater than or equal to upload_max_filesize
post_max_size = 55M

After modifying the php.ini configuration file, you need to restart your web server to use the new configuration.

Restarting Apache on CentOS Stream 9

systemctl restart httpd

You can create a php info file in order to check the current values. Create the following file phpinfo.php and put the following code inside it:

<?php
phpinfo();
?>

Access this file in your browser (http://yourdomain.com/info.php), and check the updated values. Don’t forget to delete this file after checking for security reasons.

If changes to php.ini are not reflecting in PHP's phpinfo() check if php-fpm is running by this command:

ps aux | grep php-fpm

php-fpm stands for "FastCGI Process Manager" for PHP and it was probably built in your system. If so, you have to restart it.

For CentOS

systemctl restart php-fpm.service

For more information:

http://www.php.net/manual/en/ini.list.php
http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
http://www.php.net/manual/en/ini.core.php#ini.post-max-size

Popular (all time)

Related articles

How to Edit Your WordPress Admin Username and Author Slug via MySQL

In this guide, we’ll walk you through the process of editing both the admin username and author slug using MySQL. Whether you’re looking to strengthen your site's security or simply personalize your author URL, this straightforward method will help you make the changes with ease.

Getting Started with React

In this guide, we will cover the basics of setting up a local development environment, starting a simple React project, and the basics of how it works.

How to Simplify Your Terminal with Custom Bash Aliases

By creating custom shortcuts for your most-used commands, you can save time, reduce errors, and make your terminal experience faster and more enjoyable. In this guide, we’ll show you how to create and manage your own Bash aliases to simplify your terminal workflow and boost your productivity.