How to fix : http error image upload to media library in WordPress
WordPress http error image upload is a popular error that indicates that something went wrong during the file upload process. Specifically, it occurs when you try to add an image or other sorts of files to the media library. In general, this error can be easily fixed in many different ways. In this post, Arrowtheme will give you several outstanding methods you should know to resolve http error image upload to the media library in WordPress effectively. Thus, explore with us right now!
What is the WordPress HTTP error image upload?
When utilizing the built-in media library function to upload images or videos, if something goes awry, it will result in a WordPress HTTP error. Besides, unlike browser failures that normally provide an HTTP status code, WordPress errors can be a little more difficult to detect.
In many cases, you can’t figure out what’s wrong if the “HTTP error” happens. Because there could be a number of reasons for this error, and WordPress doesn’t know which one to blame, so it just throws out a generic error message as you can see in the following image.
How to fix: http error image upload to media library in WordPress successfully?
In fact, a client-side or user error (your login session, bad characters in the file name, etc.) and a problem or setting on your WordPress host are the two most common causes of the WordPress HTTP error. In this section, we will come up with several outstanding and easy ways you should know to fix this error.
1. Refresh your page
When you get a WordPress HTTP error, the first way we highly recommend is to refresh the website in your browser. First and foremost, your browser may have lost connection with WordPress for whatever reason, and the procedure may have simply failed to complete. In reality, this could be caused by your ISP, a momentary error with your WordPress server, etc. The wordpress http error image upload will occasionally fix itself if you refresh the page and try uploading again.
Secondly, in many cases, it can throw you out after refreshing the page or returning to the WordPress editor from another tab. Your WordPress login session has most likely expired, the following message should appear:
In that case, you will most likely log back in and try to upload your files once more. And, surely, the HTTP error will occur. Hence, you will need to manually reload the page you’re viewing after logging back in. Then you will be able to upload media again.
2. Shrink or resize the image file
To fix this error, you may need to make changes to your image file, such as reducing the file size (KB or MB) or the width/height (pixels). When you upload your image to the media library, you can utilize a variety of third-party image optimization plugins to perform this for you. Most crucially, you must ensure that whichever plugin you use optimizes photos on their own servers rather than locally. If you are bulk optimizing images locally, this can have a significant negative impact on the performance of your website.
Moreover, you can completely use high-resolution photographs because WordPress already supports responsive images. In fact, you will probably want to do so so that the image on retina displays seems crisp. However, you need to keep your final image size around 100 KB and no larger than double the width of your content div on your page. Not only that, you may also need to experiment with the PNG and JPG file formats. Depending on the sort of photograph, one may be significantly larger than the other. Furthermore, you can look into increasing the WordPress maximum upload file size, depending on your WordPress host’s configuration.
3. Rename the image
If you’re uploading a picture that already exists, it is better that you add a -1 or -2 at the end. In particular, in case you don’t include the dash, Google will see it as a single word, resulting in harm to your SEO. Besides, you also need to avoid uploading images with file names that contain special characters including symbols and characters from other languages, such as apostrophes.
4. Enable plugins
If you get a wordpress http error image upload error after installing a plugin, the best thing you can do is deactivate it. Image optimization plugins are known as one of the most common causes of this problem. As a result, if you’re using an image optimization plugin, let’s turn it off and try uploading the image again. In addition, if the HTTP problem goes away, you might want to hunt for another image optimizer plugin. Alternatively, you might try contacting the plugin’s developers to further troubleshoot the issue.
5. Ask your WordPress host
The next way to resolve this error is to contact your WordPress host for help. Many of the subsequent troubleshooting tasks are a little more technical, and you can often have your host perform or check these for you.
6. Increase PHP memory limit
Another reason for the WordPress HTTP error is that your server does not have enough RAM to complete the background upload operation. With shared WordPress hosting, this is a pretty common issue. To fix the problem, you will need to increase PHP’s memory limit to a minimum of 256 MB.
How to increase PHP memory limit with wp-config.php?
You have to add the following code to your wp-config.php file in order to increase the PHP memory limit.
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
Increase PHP Memory Limit in cPanel
If your WordPress host uses cPanel, you have two options for increasing the PHP memory limit.
First and foremost, it can be found under the software category. For more details, let’s select “Select PHP Version“. Then, you must choose “Switch to PHP Options“. You may then alter the value of “memory_limit” by clicking on it.
On the other hand, the second area is also found under the software tab. To begin, you must select the “MultiPHP INI Editor” tool. This gives you access to the php.ini configuration file. After that, you just need to simply scroll down to “memory_limit” and change it to a higher value.
How to increase PHP Memory Limit with php.ini?
If you have access, you can also edit the php.ini file directly. To do so, all you have to do is use FTP or SSH to connect to your site, then navigate to the root directory and open or create a php.ini file. Besides, if the file already exists, you must look for the “memory_limit” setting and make any necessary changes.
For activating php.ini file settings, certain shared hosts may also require you to include the suPHP directive in your .htaccess file. Then, to do so, let’s update your .htaccess file, which is also at the root of your website, and add the following code at the top of the file:
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/yourusername/public_html
</IfModule>
Using .htaccess to increase the PHP memory limit
The .htaccess file is a hidden file that contains numerous settings that can be used to affect server behavior down to the directory level. To begin, you must connect to your site through FTP or SSH and check your root directory for a .htaccess file. If there is, you are able to alter the “php_value_memory_limit” value in that file.
7. Check the permissions of uploads folder
When a folder permissions error occurs, WordPress should display a notice stating that it is unable to write to the directory. What’s more, there could be a number of concerns with permissions if a WordPress site has been hacked or infected with malware.
In addition, the /wp-content/uploads folder is where files are stored when uploaded using the media library. Plus, all folders should be 755 (drwxr-xr-x) or 750, according to the WordPress Codex. Moreover, with an FTP client, you can simply examine your folder permissions. Then, you might also contact your WordPress host’s support staff and request that they immediately GREP file permissions on your directories and files to confirm that they’re properly set up. However, if you manually adjust the permissions on this folder, you need to make sure to check both the “Recurse into subdirectories” and the “Apply to directories only” options.
8. Update to the newest version of PHP
In fact, PHP 7.3 or higher is highly recommended by WordPress. Hence, you should utilize the most recent and supported versions of PHP. This is because they provide greater security and speed, as well as bug fixes and deprecated functionality. In particular, older versions of PHP have been linked to a variety of issues, including the common WordPress HTTP error.
Alternatively, in case your web host uses cPanel, you can have the opportunity to alter your PHP version. Following that, just need to simply log into cPanel and select “Select PHP Version” from the “Software” category. After that, you are able to choose from the PHP versions that your host supports.
9. Resolve performance problems with Imagick and Shared Hosts
For image processing, WordPress uses two separate PHP modules: GD Library and Imagick. If you are utilizing WordPress, you may use either one, depending on what is installed on your server. Besides, the issue is that shared WordPress hosting implements a lot of covert resource throttling. That’s the only way they can fit so many people on one computer. Moreover, having too few resources available to Imagick is one of the most common problems. What’s more, the ability to use multiple threads will be limited by hosts, resulting in the wordpress http error image upload.
Then, you can change the thread limit value to anything greater by adding the following code to the top of your .htaccess file.
MAGICK_THREAD_LIMIT 1
On the other hand, you can utilize the GD library rather than Imagick. For more details, you just need to simply add the following code to your theme’s functions.php file to accomplish this.
function wpb_image_editor_default_to_gd( $editors ) {
$gd_editor = ‘WP_Image_Editor_GD’;
$editors = array_diff( $editors, array( $gd_editor ) );
array_unshift( $editors, $gd_editor );
return $editors;
}
add_filter( ‘wp_image_editors’, ‘wpb_image_editor_default_to_gd’ );
10. Delete custom media library path
It’s possible that your media library path is incorrectly configured that causes the wordpress http error image upload. This is most common when users move their local development site to production. If you find a file path value mentioned in “Media” under “Settings” in your WordPress dashboard, all you have to do is delete it and click “Save Changes”. In particular, your media should be saved in the /wp-content/uploads folder by default.
11. Disable mod_security
The WordPress http error image upload can be caused by Mod_security that is an open source firewall. By placing the following code at the beginning of your .htaccess file, you can disable mod_security.
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Furthermore, in case you are using cPanel, you can also disable it by going to the “Security” section and clicking “ModSecurity”.
Then, you have to change the status of the domain you wish to disable from “On” to “Off”.
12. Set up the Add From Server plugin
The last way you can apply to fix: http error image upload to media library in WordPress is install the Add From Server plugin. In fact, this plugin was created with the intention of allowing you to upload very huge files via SFTP and is quite useful to work around the problem. However, it is no longer being updated or supported so that you must use it at your own risk.
>>> Read more: How to preview and edit mobile version of WordPress site
In conclusion
To sum up, there are a variety of effective approaches to resolving the WordPress http error image upload. Hence, we hope that one of the options we mentioned above worked for you and you are back on track with your media uploads. However, in case you face this problem on a regular basis, it is better that you need to upgrade to a more capable WordPress host.
Best of all, we also come with WordPress Packages with a lot of wonderful solutions. For more details, we offer a discount program that allows you to save upto 30% off for all of our WordPress Maintenance & Support services. If you need any help or have any questions, just simply contact us by filling out our CONTACT FORM. We will connect with you as soon as possible.