Increasing the upload file size limit in WordPress allows you to upload larger images (or other media) without errors. Many hosting providers set a default upload limit (often anywhere from 2 MB to 500 MB) at the server level. If you try to upload a file larger than this limit, WordPress will show an error such as “the uploaded file exceeds the upload_max_filesize directive in php.ini”. In this guide, we’ll walk through several methods to raise the upload size limit on a WordPress site hosted on cPanel. We will cover editing the .htaccess
, php.ini
, and wp-config.php
files, explain how to locate or create each file via cPanel’s File Manager, and discuss best practices, potential conflicts on shared hosting, and fallback options (like using a plugin or contacting your host).
Note: Before making any changes, it’s wise to back up your site and these configuration files. A small typo in .htaccess
or wp-config.php
can cause site errors, so having a backup lets you revert if needed. Also, try one method at a time – you usually don’t need to apply all methods, and using multiple methods simultaneously might lead to conflicting settings.
1. Checking Your Current Upload Limit
Before changing anything, check what your site’s current upload size limit is. In your WordPress admin dashboard, go to Media » Add New. At the bottom of the upload screen, WordPress displays the “Maximum upload file size” allowed (e.g. “Maximum upload file size: 2 MB”). You can also find this info under Tools » Site Health » Info » Media Handling or Server sections (look for “Max size of an uploaded file” or “upload_max_filesize”). Knowing the current limit will confirm if your changes work later.
If you’ve already encountered an error while uploading, WordPress likely told you the file exceeded a certain size. Make note of that size (e.g. 2 MB, 16 MB, etc.) so you know what the old limit is.
2. Method 1: Increasing Upload Size via .htaccess
The .htaccess
file is an Apache configuration file that WordPress uses (on Apache/LiteSpeed servers) for things like permalinks. You can also add PHP directives here to increase upload limits, if your server allows it. This method works on many cPanel hosts, but note that if your host runs PHP in CGI/FastCGI mode (common in shared hosting), using php_value
directives in .htaccess
may cause a 500 Internal Server Error. We’ll address what to do in that case shortly.
Steps to edit .htaccess:
- Open cPanel File Manager and locate your site’s root folder. Log in to cPanel and click File Manager (usually under the “Files” section). Navigate to your site’s document root directory – for a primary domain, this is often the public_html folder. If WordPress is in a subfolder or addon domain, go to that folder.
- Enable view of hidden files (dotfiles). The
.htaccess
filename begins with a dot, so it’s hidden by default. In File Manager, click the Settings button (typically top-right) and check “Show Hidden Files (dotfiles)”, then click Save. This will reveal files like.htaccess
that were previously invisible. If you don’t see a Settings button, your host’s File Manager might show a prompt to display hidden files when you open it. Make sure this option is enabled. In cPanel’s File Manager preferences, enable “Show Hidden Files (dotfiles)” to ensure you can see the.htaccess
file. By default, files beginning with a dot are hidden, so this setting must be checked. Once enabled, any hidden files (like.htaccess
) will become visible in the directory listing. - Find the
.htaccess
file in the root folder. With hidden files now visible, look for .htaccess in the public_html (or your WordPress root) directory. If your WordPress permalinks are working, this file likely already exists. You should see it listed alongside files likewp-config.php
and folders likewp-content
, etc. The.htaccess
file as shown in the public_html directory (highlighted). If this file is missing, you can create a new one via the “+ File” option in File Manager. Ensure you name it exactly.htaccess
(with the dot at the beginning). - Edit the
.htaccess
file. Right-click on.htaccess
and choose Edit (or Code Edit). If prompted for character encoding, you can proceed with default (usually UTF-8). Be careful not to remove existing WordPress rules in this file. Scroll to the bottom (or find a suitable place) and add the following lines:php_value upload_max_filesize 128M php_value post_max_size 128M php_value max_execution_time 300 php_value max_input_time 300
These lines increase the PHP limits when your site runs under Apache:php_value upload_max_filesize 128M
– sets the maximum size of an uploaded single file to 128 megabytes. You can adjust this number as needed (e.g.64M
,256M
, etc.).php_value post_max_size 128M
– sets the maximum size of POST data to 128 MB. This must be equal or larger thanupload_max_filesize
. It defines the total size of the request (file + form data) that PHP will accept.php_value max_execution_time 300
– increases the script execution time to 300 seconds (5 minutes). This helps prevent timeout errors when uploading or processing a large file.php_value max_input_time 300
– increases the time PHP will spend parsing input (such as a file upload) to 300 seconds. Similarly, this is to prevent timeouts for big uploads.
.htaccess
. - Test the new limit. In WordPress, go back to Media » Add New. The maximum upload size displayed should now reflect the new value (around 128 MB in this example). Try uploading a file larger than the old limit but smaller than the new limit to confirm the change. If it uploads successfully, the method worked. If you still see the old limit or get an error, we will try another method below.
Potential issues: If after adding those lines your site starts throwing a 500 Internal Server Error, it likely means your server does not allow PHP overrides in .htaccess
(common when PHP runs as CGI/FastCGI rather than an Apache module). In that case, you should remove those lines (restore the .htaccess
to its previous state) to get your site working again, and use one of the methods below instead. Some hosts also disable using .htaccess
for PHP settings altogether on certain plans. Don’t worry – you can achieve the same result with a php.ini
or wp-config.php
change.
3. Method 2: Increasing Upload Size via php.ini
(or .user.ini
)
PHP’s main configuration is controlled by a php.ini file. On many cPanel hosts, you can create a custom php.ini in your account to override specific settings like upload size. In modern cPanel environments with PHP-FPM, you might instead use a file named .user.ini
for per-directory PHP settings (the syntax is the same as php.ini). We will describe using php.ini, but check with your host documentation if .user.ini
is required. (If your host uses cPanel’s MultiPHP INI Editor, that tool is effectively editing your php.ini for you – we’ll note that in a moment.)
Steps to edit or create php.ini:
- Locate the php.ini file (if it exists). In cPanel’s File Manager, still in your site’s root folder (public_html), see if a file named php.ini already exists. It may or may not be present on shared hosting. Commonly, if you have used cPanel’s PHP editors or your host provided one, it might be there. If you find
php.ini
, right-click and choose Edit. - If no php.ini is found, create one. If you don’t see a php.ini, you can create a new file in the root folder named php.ini (or use the + File button to create it). In some cases, the host might require naming it .user.ini – you can create that as well, but usually cPanel with PHP versions >7 will recognize php.ini in the root for custom settings. (Alternatively, some hosts have a “MultiPHP INI Editor” in cPanel that lets you set PHP values without manually editing files. Using that GUI will achieve the same outcome by updating your php.ini behind the scenes. If you prefer, you can use that tool by selecting your domain and then changing upload_max_filesize and post_max_size there.)
- Edit php.ini to add upload size directives. Open the php.ini file (newly created or existing) and add the following lines (or modify them if they already exist):
upload_max_filesize = 128M post_max_size = 128M memory_limit = 256M max_execution_time = 300 max_input_time = 300
Explanation of these settings:- upload_max_filesize = 128M – sets the upload limit per file to 128 MB (same as in the .htaccess method). Change “128M” to your desired file size limit.
- post_max_size = 128M – allows POST requests up to 128 MB. This must be at least as large as
upload_max_filesize
. If you set one to 256M and not the other, the smaller one will bottleneck your uploads. - memory_limit = 256M – (Optional but recommended) increases PHP memory available. When handling large uploads or image processing, more memory may be needed. We set it to 256 MB here, but you can adjust as needed. Ensure this value is equal or greater than the file size you set, especially if you’ll be manipulating images or other memory-intensive operations.
- max_execution_time = 300 – increases script time limit to 300 seconds. This pairs with the above to ensure the script can run long enough for big uploads.
- max_input_time = 300 – increases input parsing time to 300 seconds, for the same reason.
- Verify the changes. It’s a good idea to double-check that your new values are actually being applied. One way is to create a PHP info file: using File Manager, create a new file (e.g.
info.php
) in public_html with the content<?php phpinfo(); ?>
. Visit this file in your browser (e.g.https://yourdomain.com/info.php
) and look for upload_max_filesize and post_max_size values in the output. They should show “128M” (or your set value). You can delete the info.php file afterward. Alternatively, in WordPress, go to Tools » Site Health » Info » Server and confirm the “Upload max filesize” reflects the new value. - Test uploading a file. Again, try uploading a file via Media library that’s larger than the old limit and under the new limit. If it works without error and the limit displayed is higher, the php.ini method was successful. WordPress should now allow images (and other files) up to the size you configured.
Important: On shared hosting, some providers do not allow custom php.ini changes or they cap the maximum you can set. Hostinger, for example, notes that many shared hosts won’t allow editing php.ini directly and you should confirm with support if you can modify it. If you find that even after editing php.ini the limits don’t change, the host might be ignoring your php.ini (or requiring a different file like .user.ini). In that case, contacting the host support or using their provided interface (like MultiPHP INI Editor) is recommended. Additionally, keep your php.ini in the correct directory – if WordPress is in a subfolder, the php.ini might need to be placed there or in the home directory, depending on how the host loads configurations. Check your host’s knowledge base for “custom php.ini” instructions if unsure.
4. Method 3: Increasing Upload Size via wp-config.php
Another approach is to apply settings in WordPress’s configuration file wp-config.php. This file resides in the root of your WordPress installation and controls many aspects of WordPress. By adding some PHP directives here, you might increase the upload limits. However, note that this method is not always effective for upload size limits – because the server may evaluate the maximum file size before WordPress (and thus wp-config) is fully loaded. Still, it can be a useful supplement, especially for increasing memory limits, and it’s easy to try since you already have access to the file.
Steps to edit wp-config.php:
- Locate wp-config.php in File Manager. In the same root folder (public_html or your WP folder), find wp-config.php – it should be visible (this one is not hidden). If you’re in public_html, you will see
wp-config.php
alongside wp-content, wp-admin, etc. Right-click wp-config.php and choose Edit. - Open the file for editing. When the editor opens, you will see many lines of configuration (database settings, salts, etc.). Scroll down toward the bottom of the file. Look for the line that says:
/* That's all, stop editing! Happy publishing. */
It’s typically near the end. Above that line, add the following code snippet (or you can add it anywhere above the comment, but placing near the end keeps things organized):// Increase PHP upload limits @ini_set( 'upload_max_filesize' , '128M' ); @ini_set( 'post_max_size', '128M'); @ini_set( 'memory_limit', '256M' );
And optionally, you can also add:define( 'WP_MEMORY_LIMIT', '256M' );
Here’s what each line does:@ini_set( 'upload_max_filesize' , '128M' );
– Attempts to set the PHP upload_max_filesize to 128 MB at runtime (the@
suppresses any warning if it fails). This is the same directive we set in php.ini earlier.@ini_set( 'post_max_size' , '128M' );
– Attempts to set post_max_size to 128 MB.@ini_set( 'memory_limit' , '256M' );
– Increases the PHP memory limit for this script to 256 MB. This is similar to setting memory_limit in php.ini. We do this because WordPress may need more memory to handle large uploads or image processing.define( 'WP_MEMORY_LIMIT', '256M' );
– This is a WordPress-specific constant to bump up WordPress’s internal memory limit setting. By default, WordPress might limit itself to e.g. 40M for a single site. Setting this ensures WordPress itself will allow up to 256 MB usage. (This mainly affects PHP memory for WordPress operations, which indirectly helps if large images are being resized, but it does not alone change the upload file size cap. It’s a complementary setting.)
- Test the effect. Because of how PHP works, the
ini_set
calls in wp-config.php may not take effect early enough to permit a bigger file upload in the same request. However, it doesn’t hurt to have them as a fallback. After adding, try uploading a large file again or check Site Health Info. If your host allowed the .htaccess or php.ini changes, those would already have done the job. The wp-config changes are more of a safety net. In some cases (depending on host configuration), these settings could help if the upload limit was being capped by WordPress itself rather than PHP.
If this method alone doesn’t seem to raise the limit, rely on the .htaccess or php.ini methods above, as they work at the server configuration level. The wp-config.php
tweaks are best used in combination with those, especially to ensure memory is boosted. Always keep wp-config.php
edits minimal and double-check for syntax errors (a missing quote or semicolon could crash your site). If you encounter issues after editing, restore the backup of wp-config.php.
5. Best Practices and Considerations (Shared Hosting)
Increasing the upload size may be straightforward, but here are some best practices and things to watch out for, especially in shared hosting environments:
- Match or exceed related limits: Always set post_max_size >= upload_max_filesize. If post_max_size is smaller, your uploads will still fail or be truncated. Also, ensure memory_limit is high enough to handle the file – it should be at least as large as upload_max_filesize (and typically much more if you process images).
- PHP environment matters: The method that works depends on how PHP is configured on your server. If PHP is running as an Apache module (mod_php), the
.htaccess
method withphp_value
works well. If PHP runs as CGI/FastCGI (e.g. PHP-FPM or suPHP, common in shared hosting), then.htaccess
cannot override PHP settings and will cause errors. In those cases, use php.ini (or .user.ini) to set values, as the PHP process will read those on start. Some hosting control panels (like cPanel) also provide a PHP Configuration or MultiPHP INI Editor to make these changes easily via a UI – consider using those to avoid syntax mistakes. - Hosting-imposed limits: Be aware that your host may enforce an upper limit on upload file size regardless of what you set. For instance, you might set 512M, but the host’s PHP config or plan might cap it at 50M or 100M. If you find you cannot increase beyond a certain point, that is likely a host restriction. “Starter” shared hosting plans often have lower limits than higher-tier plans. In such cases, you may need to contact the host to raise the limit (they might do so if you ask, or they might require you to upgrade plans for significantly higher limits).
- File creation and permissions: When creating new files like
.htaccess
orphp.ini
, ensure they have the correct filenames (no.txt
extension, for example). The File Manager should create them with proper permissions by default (usually 644 for files). If you upload a php.ini via FTP, also ensure it’s in the correct directory and has suitable permissions. Incorrect permissions or ownership can sometimes cause the file to be ignored or cause errors. - Keep backups of config files: It’s worth reiterating – always save a copy of the original
.htaccess
orwp-config.php
before you edit. This way, if something goes wrong, you can quickly revert. Even better, make one change at a time and test, rather than changing multiple things at once. This will help isolate if a particular change caused an issue. - Avoid conflicts: Try to use one primary method to set the values. If you set different upload_max_filesize in .htaccess and php.ini, it could confuse you later. Typically, PHP will use whichever is loaded last (php.ini is loaded at startup, .htaccess could override at runtime if allowed). For clarity, pick one approach that works on your host. The exception is
wp-config.php
where adding the settings doesn’t usually conflict but may be redundant; it’s mostly for completeness. - WordPress Multisite note: If you are running a WordPress Multisite network, there is a separate network admin setting for max upload size (which defaults to 1500 KB (~1.5MB) unless changed). Increasing the PHP limits will allow higher values, but you also need to go to My Sites » Network Admin » Settings and increase the “Max upload file size” setting for the network, otherwise site admins will still be limited by that value.
6. Fallback Options (Plugins or Hosting Support)
If you have tried editing .htaccess
, php.ini
, and wp-config.php
and the upload limit still hasn’t increased, don’t despair. Here are some fallback options:
- Use a WordPress plugin: There are plugins specifically designed to increase the upload size limit. One popular option is the “WP Increase Upload Filesize” plugin. After installing and activating such a plugin, it often provides a settings page (for example, under Media » Increase Upload Limit) where you can select a new maximum upload size from a dropdown. Under the hood, these plugins typically try to update the same settings we did manually (or use WordPress filters) – but they provide a user-friendly interface. Keep in mind that a plugin cannot bypass server-level restrictions; for instance, it will not allow you to set a value higher than what the server allows. In fact, WP Increase Upload Filesize will show you the maximum possible limit (based on server config) in its dropdown, and if you need more, it will advise contacting your host. Using a plugin can be convenient if you’re not comfortable editing files, but since you do have cPanel access, it’s essentially doing the same thing you’ve attempted.
- Contact your hosting support: This is often the simplest and most reliable solution. Hosting providers deal with upload limit requests frequently, and it’s usually a trivial change for them (especially if you are on a managed plan). Reach out to your host via phone or support ticket or chat, and ask “Can you increase the PHP upload_max_filesize and post_max_size for my account? I need to upload files of X MB.”. Specify the size you need. Many hosts will gladly increase it or tell you the maximum they can allow on your current plan. Some hosts have documentation for this; others might guide you to a specific solution for their environment (like a custom php.ini location or a control panel setting). If the host says you’re at the maximum for your plan, you might consider an upgrade if it’s critical for your site, or use an alternative approach (e.g., upload via FTP and then import, which sidesteps PHP upload limits).
- Alternative upload methods: As a last resort, if you cannot increase the limit and the host won’t assist (or you need a one-time upload of a huge file), you could upload the file via FTP or cPanel’s File Manager, placing it in
wp-content/uploads
(or a subfolder by date), and then use a plugin like “Add From Server” or a custom script to import it into the WordPress Media Library. This bypasses PHP’s upload size restrictions since you’re not going through PHP’s upload mechanism. However, this is usually unnecessary if you can get the configuration updated by using the earlier methods or your host’s help.
7. Conclusion
By using one or a combination of the methods above, you should be able to raise the maximum image upload size for your WordPress site on cPanel hosting. In summary, editing the PHP settings via .htaccess
or php.ini
has a server-wide effect for your site and is the most direct way, while WordPress config tweaks and plugins provide additional ways to ensure the limits are increased. Always be mindful of the environment – on shared hosts there may be caps or specific procedures to follow. Once the new limits are in place, you’ll be able to upload higher-resolution images, large media files, or hefty plugins/themes as needed. Monitor your site after making these changes to ensure it’s stable, and enjoy the greater freedom in managing your media. Happy publishing!
Sources
- WPBeginner – How to Increase the Maximum File Upload Size in WordPress
- Hostinger – How to Increase the Maximum Upload File Size in WordPress
- cPanel Community – Viewing Hidden Files in File Manager
- Reddit (r/webdev) – php_value in .htaccess causing 500 error
- PHP Manual – ini_set limitations for upload_max_filesize
- IONOS – WordPress Upload Limit Tips
- Kinsta – Why hosts impose upload limits
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND