How to Increase PHP File Upload Size Limit

The default PHP file upload size limit is often set to a low value, which can be insufficient for uploading large files through web applications or content management systems. In this guide, we will show you how to increase the PHP file upload size limit on different platforms.

Step 1: Locate the php.ini file

The PHP file upload size limit is configured in the php.ini file. To locate the active php.ini file, run the following command:

php --ini

The output will display the location of the php.ini file. If you are using a shared hosting environment, you may need to ask your hosting provider for the location of the php.ini file, or they may provide you with a custom interface to edit the configuration.

See also  How to Install PHP on Fedora 16

Step 2: Edit the php.ini file

Open the php.ini file using your preferred text editor. For example, if you are using the nano editor, run:

sudo nano /path/to/php.ini

Replace /path/to/php.ini with the actual path to your php.ini file.

Step 3: Update the file upload size limit

In the php.ini file, locate and modify the following directives:

upload_max_filesize = 128M
post_max_size = 128M

The values above set the maximum file upload size to 128 MB. Adjust these values according to your requirements.

Step 4: Increase the script execution time (optional)

For large file uploads, you may also need to increase the maximum script execution time. Locate and modify the max_execution_time directive in the php.ini file:

max_execution_time = 300

The value above sets the maximum script execution time to 300 seconds (5 minutes). Adjust this value according to your needs.

See also  How to Install and Configure Joomla 2.5.4 on CentOS 5.8

Step 5: Save and restart the web server

Save the changes to the php.ini file and restart your web server to apply the new settings.

For Apache:

sudo service apache2 restart

For Nginx with PHP-FPM:

sudo service php-fpm restart
sudo service nginx restart

Programs Mentioned:

  • PHP – A widely-used open-source scripting language, especially suited for web development and can be embedded into HTML.
  • php.ini – The main configuration file for PHP, which contains settings that control the behavior and functionality of PHP on your server.
See also  How to Properly Shutdown and Reboot Linux CentOS 5/CentOS 6/RHEL 5/RHEL 6

Conclusion

By following this guide, you have successfully increased the PHP file upload size limit on your server. This will enable you to upload larger files through web applications or content management systems that rely on PHP. Remember to adjust the values according to your server’s resources and requirements to ensure optimal performance.

If you have any questions, comments, or suggestions for improvements, please feel free to share your thoughts. Your feedback helps us provide the most accurate and useful information possible.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *