Increase max upload file size in WordPress Multisite network?

Learn increase max upload file size in wordpress multisite network? with practical examples, diagrams, and best practices. Covers php, wordpress, php-ini development techniques with visual explanat...

Increase Max Upload File Size in WordPress Multisite

Hero image for Increase max upload file size in WordPress Multisite network?

Learn how to configure your WordPress Multisite network to support larger file uploads by adjusting PHP and WordPress settings.

WordPress Multisite networks often have a default maximum upload file size that can be restrictive for users needing to upload larger media files, documents, or backups. This limit is typically inherited from your server's PHP configuration and can be further constrained by WordPress itself. This article will guide you through the necessary steps to increase this limit, ensuring your network can handle larger files efficiently.

Understanding Upload Limits and Their Sources

The maximum upload file size in WordPress is determined by several factors, primarily your server's PHP configuration and WordPress's own settings. It's crucial to understand that WordPress cannot override a lower limit set by PHP. Therefore, you must first ensure your PHP settings are adequate before adjusting WordPress-specific configurations. The key PHP directives involved are upload_max_filesize, post_max_size, and memory_limit.

flowchart TD
    A[User Uploads File] --> B{Is File Size > WordPress Limit?}
    B -- Yes --> C[Upload Fails (WordPress)]
    B -- No --> D{Is File Size > PHP upload_max_filesize?}
    D -- Yes --> E[Upload Fails (PHP)]
    D -- No --> F{Is File Size > PHP post_max_size?}
    F -- Yes --> G[Upload Fails (PHP)]
    F -- No --> H{Is PHP memory_limit Sufficient?}
    H -- No --> I[Upload Fails (PHP Memory)]
    H -- Yes --> J[File Upload Successful]

Flowchart illustrating the checks for file upload size limits in WordPress.

Adjusting PHP Configuration

The most common way to increase the upload limit is by modifying your PHP configuration. This usually involves editing the php.ini file, but depending on your hosting environment, you might use an .htaccess file, a custom user.ini file, or your hosting control panel. Always back up any files before making changes.

php.ini

upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 128M

Locate your php.ini file (often in /etc/php/X.X/fpm/php.ini or /etc/php/X.X/apache2/php.ini for Linux servers, or in your PHP installation directory for Windows). Adjust the values as needed. After saving, restart your web server (Apache/Nginx) and PHP-FPM if applicable.

.htaccess

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value memory_limit 128M

Add these lines to your .htaccess file in the root of your WordPress installation. This method only works if AllowOverride All is enabled for mod_php on your server. If you see a 500 Internal Server Error, your server might not allow these directives in .htaccess.

wp-config.php

@ini_set( 'upload_max_filesize', '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'memory_limit', '128M' );

While less common for PHP settings, you can try adding these lines to your wp-config.php file before the /* That's all, stop editing! Happy publishing. */ line. This method might not work on all hosting environments as ini_set can be disabled.

Configuring WordPress Multisite Network Settings

Once you've adjusted the PHP limits, you also need to update the WordPress Multisite network settings. This is done through the Network Admin dashboard. WordPress will automatically cap the maximum upload file size based on your PHP settings, but you can set a lower limit if desired.

1. Access Network Admin Dashboard

Log in to your WordPress site and navigate to 'My Sites' -> 'Network Admin' -> 'Dashboard'.

2. Go to Network Settings

In the Network Admin dashboard, hover over 'Settings' and click on 'Network Settings'.

3. Adjust Max Upload File Size

Scroll down to the 'Upload Settings' section. You will see a field labeled 'Max upload file size'. Enter your desired maximum size in KB (e.g., for 64MB, enter 65536). WordPress will display the current PHP limit next to this field, so ensure your entered value does not exceed it.

4. Save Changes

Click the 'Save Changes' button at the bottom of the page to apply your new settings.

5. Verify Changes

Visit a subsite's media uploader (e.g., 'Media' -> 'Add New') to confirm that the maximum upload file size has been updated to your desired value.