How To Fix Maximum Upload And Php Memory Limit Issues In WordPress?
Want to know how to Increase the maximum file size for uploading to WordPress? One of the most frequent errors that can occur in WordPress is when a message appears saying that PHP memory is missing.
Specifically, if you see an error like: “The uploaded file exceeds the upload_max_filesize directive in php.ini”. You will probably need to increase the maximum size allowed for downloads.
In this article, you will learn how to increase WordPress PHP memory quickly and easily.
What is a warning message related to upload and memory limit in WordPress?
While WordPress is really easy to use, there are some common WordPress mistakes that can make you panic. The good thing is that the WordPress error you see on your site is most likely reported and resolved by someone before you. Here, we have written tutorials on Common WordPress Errors and How to Fix Them.
Now understand what does that means? Let me explain: when you upload images, videos, or even plugins to WordPress, you are actually uploading files to your server space.
The WordPress platform and hosting providers place limits on the size of files that can be uploaded. If you try to upload a file that exceeds these limits, an error message is displayed.
In principle, it is always best to upload files that are as small as possible (eg Optimized Images). This makes it possible not to overload the server too much and also not to lengthen the loading time of the pages too much.
However, if you need to upload files that exceed the size limit (for example, to upload a plugin, high-quality video, or photos), there are different ways to change the default settings.
Why does WordPress need more memory, to begin with?
You have to bear in mind that your WordPress is hosted on a server, which is nothing more than a computer with special characteristics.Like any other computer, it has a certain memory to perform different functions at the same time.
Usually, the server administrator allocates memory to the applications on it, including PHP, which is the programming language that WordPress uses.
Sometimes, when your WordPress has too many plugins installed that try to perform certain functions simultaneously, they consume the maximum allocated memory, in this case showing an error on your screen that says something like:
Fatal error: The allowed memory size of xxxxx bytes exhausted (tried to allocate xxxx bytes) in /domain/xxx/public_html/wp-includes/plugin.php on line xxx.
This also tends to happen if you have WooCommerce installed on your WordPress, as it tends to consume a lot of PHP memory. They recommend having at least 64M.
How to check the Maximum Upload Limit in WordPress?
By default, the maximum upload size in WordPress ranges from 2MB to 150MB, depending on your web host’s settings.
If you are creating a WordPress website that hosts a portfolio with large image files or you need to install large plugins in size then you may not be able to upload 4-5MB files (in most cases).
Finding out the maximum upload size set for your site is simple: go to the bulletin board, navigate to Media> Add New.
Below the area where files are released, you will see a note icon where the maximum file size is indicated. Usually, the value is 24M, 32M, 64M or 128M.
You will see it boils down to opening or creating your php.ini file in the root of your WordPress installation, it will be in most cases public_html – Add the lines below and edit them according to the size you want.
upload_max_filesize = 24M
Solution
How to fix maximum upload and PHP memory limit issues in WordPress?
If your WordPress site is hosted on shared web hosting or hosting, it is likely that you may sometimes encounter the error message that the size of the allowed memory has been exhausted.
Web servers are practically the same as a computer, they need memory to process requests and scripts from the hosted sites. When an amount of information is executed, when you reach the memory limit, you will end up seeing this error.
In this short basic tutorial, we will show you a simple solution to increase the PHP memory limit on your server, with a choice of 3 methods.
Check with the hosting provider
If you want to increase the maximum file upload size to WordPress, the first thing we recommend is to contact your web host to explain your needs.
Hosting providers that specialize in WordPress hosting have a default option to increase the file upload size limit (often located in the control panel).
Often, web hosts configure their servers so that there are download limits. In these cases, even if you change the default WordPress settings, you would still not be able to upload files of the desired size.
First, contact the hosting service you have chosen to use. The more popular ones, such as Bluehost and HostGator, have chat support services and are generally very available and efficient at resolving these types of requests.
Modify (or Create) php.ini
php.ini (located in the root directory of the hosting account) is a configuration file that customizes the behavior of PHP at runtime. Contains a list of settings including maximum upload file size, maximum execution time, upload directory, global variables, and display errors.
Due to security concerns, almost all hosting providers keep it hidden. To access the file, log into your hosting account, navigate to the root directory, and search for php.ini. You may need to check “Show hidden files”.
If no such file exists, create a new one with the name: “php.ini”.
Make sure the file includes the three variables mentioned above.
Since we need to set the maximum file upload size to 20MB, we will change the values of upload_max_filesize to 20MB and post_max_size to 25MB so that a single 20MB file can be used in the body of the message. A good practice is to set a post_max_size size larger than the upload_max_filesize size.
upload_max_filesize = 20Mpost_max_size = 25Mmemory_limit = 30M
Note: “M” refers to “MB”, the memory limit must be equal to or greater than the size of the upload_max file. To be safe, we have set it to 30MB.
Note that some hosting providers rename the file to php5.ini.
Modify (or Create) the .htaccess file
.htaccess is short for Hypertext Access, a configuration file used by Apache servers. Typically, it is located in the root directory. If the file is not there, create it with the exact name and extension “.htaccess”
We assume you already have the file, copy and paste the following lines of code just below where it says #End WordPress.
php_value upload_max_filesize 20MBphp_value post_max_size 25MBphp_value memory_limit 30M
Note: While searching .htaccess, don’t forget to check “Show hidden files”. It could be hidden by your hosting provider.
Other methods
The above three methods are the most recommended ways to increase the file upload size. However, for whatever reason these methods don’t work, it’s time to add something more to WordPress files.
Modify WordPress files
Open the wp-config.php or functions.php files and paste the following lines of code:
@ini_set (‘upload_max_size’, ’20MB’);@ini_set (‘post_max_size’, ’25MB’);@ini_set (‘memory_limit’, ’30MB’);
Increase WordPress Max Upload File Size through Plugin
The beauty of WordPress is that you will always find a plugin to solve the problem.
If you don’t want to increase the size of the uploaded file manually, there is an excellent plugin called WP Increase Upload File size that will surely help you. Just remember to enter the values in bytes (1024000 bytes = 1MB).
For 20 MB, multiply 1024000 by 20 and enter 20480000 in the text box. Click Save Changes and voila!
Conclusion
By using any of these methods, you should have been able to increase the maximum file size for uploading to WordPress.
WordPress is a commonly used CMS, globally around 60% of websites are developed in WordPress. The plugin helps to make a WordPress website more appealing but also secure. But plugins can also cause vulnerability and can be a reason for the attack of malware. You can use various WordPress malware removal tools which help you detect malware or to fix your WordPress website. There are some best WordPress malware scanners available that give the best result.
The post How To Fix Maximum Upload And Php Memory Limit Issues In WordPress? appeared first on WPressBlog.
Read more: wpressblog.com
Leave a Reply