How do I increase the upload_max_filesize and post_max_size for larger uploads?

How do I increase the upload_max_filesize and post_max_size for larger uploads?

Answer: Edit your php.ini file to increase upload limits and restart your PHP-FPM or Apache service.

PHP Configuration:

Edit your php.ini file with these settings:

upload_max_filesize = 100M
post_max_size = 100M

Additional Settings:

For very large uploads, also adjust:

max_execution_time = 300
max_input_time = 300
memory_limit = 256M

Restart Services:

After making changes, restart your web server:

  • Apache: sudo systemctl restart apache2
  • Nginx + PHP-FPM: sudo systemctl restart php8.1-fpm
  • Both: sudo systemctl restart nginx

Verification:

Check your current settings:

php -i | grep -E "(upload_max_filesize|post_max_size)"

Alternative Methods:

Using .htaccess (if allowed):

php_value upload_max_filesize 100M
php_value post_max_size 100M

Using ini_set() in PHP:

ini_set('upload_max_filesize', '100M');
ini_set('post_max_size', '100M');