One of the most frustrating errors WordPress users encounter on shared hosting is being unable to upload files — whether images, theme packages, plugins, or media assets. The error messages vary: "The uploaded file exceeds the upload_max_filesize directive in php.ini," "HTTP error," or simply a silent failure with no file appearing in the media library. In nearly all cases, the root cause is a PHP upload limit that is set too low by default. This guide covers every method for increasing the upload limit on DirectAdmin hosting, explains exactly why each approach works (or does not), and provides ready-to-use configuration snippets.
Understanding the 5 PHP Settings That Control File Uploads
Before attempting any fix, it is important to understand that PHP enforces file upload restrictions through several interrelated configuration directives, not just one. All of them must be set correctly for uploads to succeed. If even one directive has a value lower than what is needed, the upload will fail regardless of how the others are configured.
| PHP Directive | Default | What It Controls | Recommended |
|---|---|---|---|
upload_max_filesize |
2M | Max size per individual file | 64M or 128M |
post_max_size |
8M | Max size of entire POST request | 128M (must exceed upload_max_filesize) |
memory_limit |
128M | Max memory per PHP script | 256M |
max_execution_time |
30 | Max script run time (seconds) | 120–300 |
max_input_time |
60 | Max time to receive input (seconds) | 120–300 |
The critical rule to remember is that post_max_size must always be larger than upload_max_filesize. A POST request carries the file data plus form metadata, so if post_max_size is equal to or smaller than upload_max_filesize, PHP will truncate the request before it can process the file content. This is a common misconfiguration that causes uploads to silently fail or produce cryptic errors.
Method 1 — Use the DirectAdmin PHP Configuration Panel
The easiest and most reliable approach is to change the PHP settings directly in the DirectAdmin control panel. This method applies the change globally to your hosting account and does not require creating any additional files.
- Log in to DirectAdmin with your hosting username and password.
- Navigate to Account Manager and click PHP Configuration or PHP Selector.
- Select the PHP version currently active on your account (e.g., PHP 8.3).
- Find upload_max_filesize and change it to
64Mor128M. - Find post_max_size and set it to a value larger than upload_max_filesize (e.g.,
128Mor256M). - Save your changes and wait a moment for PHP to reload.
After saving, verify the change by checking WordPress admin under Media > Add New. The maximum upload size shown there should reflect the new limit. Alternatively, create a temporary phpinfo file to confirm the values took effect.
Method 2 — Create a php.ini File in public_html
If your hosting provider allows per-directory php.ini files — which many DirectAdmin hosts do — this method provides a persistent override that survives server-level PHP config updates. Create a file named php.ini in your public_html root directory with the following content:
upload_max_filesize = 128M post_max_size = 256M memory_limit = 256M max_execution_time = 300 max_input_time = 300
To verify that the file is being read, create a temporary test file named check.php in the same directory:
<?php
echo 'upload_max_filesize: '.ini_get('upload_max_filesize').'<br>';
echo 'post_max_size: '.ini_get('post_max_size').'<br>';
echo 'memory_limit: '.ini_get('memory_limit').'<br>';
?>
Open https://yourdomain.com/check.php in your browser. If the values still show the old defaults, the server does not support per-directory php.ini files — move on to Method 3. Always delete check.php after testing, as leaving PHP info files accessible publicly is a security risk.
Method 3 — Use a .user.ini File (PHP-FPM Environments)
Modern hosting environments — including most DirectAdmin setups — use PHP-FPM (FastCGI Process Manager) rather than Apache mod_php. In PHP-FPM mode, the php_value directive in .htaccess has no effect. The correct alternative is a .user.ini file, which uses identical syntax to php.ini and is specifically designed for per-user directory overrides in FastCGI setups.
Create a file named .user.ini (note the leading dot) in your public_html directory:
upload_max_filesize = 128M post_max_size = 256M memory_limit = 256M max_execution_time = 300 max_input_time = 300
One important caveat: PHP-FPM caches the contents of .user.ini files. By default, the cache TTL is 300 seconds (5 minutes). This means you may need to wait up to 5 minutes after creating or editing the file before the new settings take effect. You can also ask your host if they can clear the PHP-FPM configuration cache to speed up the process.
Pro tip: If you are unsure whether your server uses mod_php or PHP-FPM, create both php.ini and .user.ini with the same content in your public_html directory. PHP will automatically use the appropriate file based on how it is running. Having both files present causes no conflicts and ensures maximum compatibility.
Method 4 — Edit .htaccess with php_value Directives
This method only works when PHP runs as Apache mod_php. Open the .htaccess file in your WordPress root directory (usually public_html/.htaccess) and add the following lines:
php_value upload_max_filesize 128M php_value post_max_size 256M php_value memory_limit 256M php_value max_execution_time 300 php_value max_input_time 300
A critical warning: if your server does not support php_value in .htaccess, Apache will respond with a 500 Internal Server Error for every page on your site. If that happens, immediately remove those lines. Test with a single directive first before adding all five to minimize downtime risk.
The existing WordPress .htaccess typically contains RewriteRules for permalink handling. Add the php_value lines at the top of the file, before the WordPress-generated block that begins with # BEGIN WordPress, to avoid conflicts with the rewrite rules.
Method 5 — Configure WordPress via wp-config.php
WordPress has its own memory limit constants that can be set in wp-config.php. These constants tell WordPress how much PHP memory to request, but they cannot override the hard PHP limit set by the server — they can only request up to that limit. Open wp-config.php and add these lines before the require_once ABSPATH . 'wp-settings.php'; line:
/** WordPress Memory Limits */ define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WP_MEMORY_LIMIT applies to front-end page rendering, while WP_MAX_MEMORY_LIMIT applies to the WordPress admin area, which requires more memory for tasks like media processing and plugin management. Set both values for comprehensive coverage.
Additionally, if you need to programmatically adjust the upload size limit within WordPress itself, you can use a filter hook in your theme's functions.php:
add_filter( 'upload_size_limit', function( $size ) {
return 128 * 1024 * 1024; // 128 MB in bytes
});
Note that this filter can only reduce the upload limit, not increase it beyond what PHP allows. It is useful when you want to restrict uploads for specific user roles or contexts within WordPress.
Verifying Your Changes
After applying any of the methods above, always verify that the new settings are active before declaring the problem resolved.
Check via WordPress Dashboard
Go to Media > Add New in the WordPress admin. Below the upload area, WordPress displays the maximum upload file size. If the value still shows the old limit (such as 2 MB or 8 MB), the change has not taken effect yet.
Check via a PHP Script
Create a temporary check.php file in public_html with the following content, then access it via your browser:
<?php
$values = [
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'memory_limit' => ini_get('memory_limit'),
'max_execution_time' => ini_get('max_execution_time'),
];
foreach ($values as $key => $val) {
echo "<strong>$key</strong>: $val<br>";
}
?>
Delete this file immediately after testing. PHP info files expose server configuration details that could assist an attacker.
Understanding Configuration Priority
PHP reads configuration values from multiple sources in a defined order. Later sources override earlier ones:
- Server-level
php.ini(set by the hosting provider) - Per-directory
php.inior.user.ini(your files in public_html) php_valuein.htaccess(mod_php only)ini_set()calls in PHP code (only for changeable directives)
If a server administrator has set a hard maximum on a directive, your per-directory files cannot exceed that maximum — they can only reduce it. Contact your hosting provider if you need limits higher than what your files can set.
Troubleshooting — When Uploads Still Fail After Configuration Changes
In some cases, uploads may still fail even after correctly updating the PHP limits. Here are additional factors to investigate.
Nginx client_max_body_size
If your host uses Nginx as a reverse proxy in front of Apache and PHP, there is a separate Nginx directive called client_max_body_size that limits the size of incoming requests before they ever reach PHP. If this is set lower than your desired upload size, the upload will be rejected at the Nginx layer, and you may see a "413 Request Entity Too Large" error. This directive can only be changed by the server administrator, so contact your hosting support team and request an increase.
WordPress Nonce Expiration During Large Uploads
WordPress uses nonces (security tokens) that expire after a set period. When uploading very large files over a slow connection, the upload may take longer than the nonce lifetime, causing WordPress to reject the request with a security error. Increasing max_execution_time and max_input_time to 300 seconds or more reduces the likelihood of this happening.
Disk Quota Full
Check your disk usage in DirectAdmin under System Info & Files. If your hosting account has reached its disk quota, WordPress cannot save newly uploaded files even if the PHP limits are correct. Free up space or upgrade your hosting plan to resolve this.
wp-content/uploads Directory Permissions
The WordPress uploads directory requires write permissions. The correct permissions are 755 for directories and 644 for files. Incorrect permissions will prevent WordPress from saving uploaded files to disk. Fix them via DirectAdmin's File Manager or FTP:
# Fix permissions via SSH (if shell access is available)
chmod 755 wp-content/uploads
find wp-content/uploads -type f -exec chmod 644 {} \;
find wp-content/uploads -type d -exec chmod 755 {} \;
Recommended PHP Settings for WordPress
For a well-configured WordPress hosting environment, the following PHP settings provide a solid baseline. Sites using WooCommerce, page builders such as Elementor or Divi, or heavy plugin stacks may need memory_limit set even higher — up to 512M in some cases.
# Recommended baseline for WordPress hosting upload_max_filesize = 128M post_max_size = 256M memory_limit = 256M max_execution_time = 300 max_input_time = 300 max_input_vars = 5000
The max_input_vars directive — set to 5000 here — is often overlooked but matters significantly for WordPress sites with many active plugins. When a plugin's settings page submits a form with more input fields than max_input_vars allows (default is 1000), PHP silently truncates the data, causing settings to save incorrectly or not at all. Setting it to 5000 prevents this issue on all but the most plugin-heavy installations.
Frequently Asked Questions
Why can't WordPress upload files even when the file size seems small?
WordPress enforces multiple PHP limits simultaneously: upload_max_filesize, post_max_size, memory_limit, and max_execution_time. If any single limit is lower than the file you are trying to upload, the upload will fail. Also, post_max_size must always be larger than upload_max_filesize because POST requests include the file data plus form metadata.
Where do I change PHP settings in DirectAdmin?
In DirectAdmin, go to Account Manager > PHP Configuration or Extra Features > PHP Settings. From there you can directly change upload_max_filesize and post_max_size. Alternatively, create a php.ini file in your public_html directory to override server-level settings. Some hosting setups also support .user.ini files.
What is the difference between upload_max_filesize and post_max_size?
upload_max_filesize is the maximum size for each individual uploaded file. post_max_size is the maximum size of the entire HTTP POST request body, which includes all uploaded files plus any other form data. Therefore, post_max_size must always be greater than upload_max_filesize — for example, if upload is 64M, set post to at least 128M.
I edited .htaccess but uploads still fail. What should I try next?
The php_value directive in .htaccess only works when PHP runs as Apache mod_php. If your host uses PHP-FPM or CGI mode (which is common on modern servers), .htaccess php_value has no effect. Try using a .user.ini file instead — place it in your public_html directory with the same syntax as php.ini, for example: upload_max_filesize = 64M and post_max_size = 128M.
DirectAdmin Hosting by AsiaGB
AsiaGB Hosting includes full DirectAdmin support, PHP 8.3, MySQL, and generous PHP limits. Starting from 500 THB/year.
View Hosting Plans