I am getting an HTTP error on uploading image to wordpress. Help me!
This is a support request we sometimes get as a part of our white label technical support for WordPress hosting providers.
WordPress users would try to upload a file, but it’ll fail with the error as shown here:
We have seen many reasons for this error, and we will today show you the top 10 reasons for this error, and how we fix it.
Common reasons for http error on uploading images to wordpress:
The http error on uploading image to WordPress can occur due to a variety of reasons. The common ones are listed below:
- Properties of the image.
- Permission issue with the uploads folder.
- Low PHP Memory limit.
- Issues with image editor library.
- Browser issue.
- Plugin conflict.
- PHP version conflicts.
- ModSecurity issues.
- Temporary issues.
Turning on the error display in WordPress can help us to get some leads. This can be done easily by changing the value for “WP_DEBUG” to true in the WordPress configuration file.
Let us now discuss how our Support Engineers fix the http error message in uploading images to WordPress in each case.
1. Adjust the properties of the image
Sometimes the size of the image file or the file name can cause issues while uploading it to WordPress. Reducing the file size or width/length(pixel) can help in fixing this issue. In most cases, a good image optimization plugin should be able to fix it.
If there is already a file uploaded to WordPress with the same name as the file that we are trying to upload now, it can trigger http error. WordPress automatically tries to append a number at the end of the filename, but it may not work in all the cases. Changing the filename manually can fix this issue.
If you are using cPanel, it can be changed easily from the rename option in File Manager.
2. Fix the permission of the uploads folder
The recommended permission for folders in WordPress is 755. Any change in these settings for the WordPress upload folder will typically trigger an unable to upload error. However, the error messages may vary based on other server settings.
Changing the permission back to the required value will fix the issue in this case.
3. Increase PHP memory limit
The image upload may trigger the http error if sufficient memory is not available for it. The recommended value of PHP memory limit for WordPress is 256MB.
PHP memory limit can be changed at your hosting end. If you are using cPanel, it can be easily changed from the MultiPHP ini editor option in cPanel
4.Changing the Image editor Library
WordPress uses both GD Library and Imagick modules to handle images. Some web hosts especially in shared hosting environments limit the resources provided to each account. In the event that if sufficient memory is not available for Imagick to work, it may trigger the http error.
It can be fixed by making GD library to handle images. Following code in theme’s function.php can accomplish it.
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’ );
5. The .htaccess method
The issue with Imagick can be corrected by limiting the resource usage of Imagick as well. Instead of setting code to use only GD library, following code added in .htaccess file will make Imagick use a single thread to process images.
SetEnv MAGICK_THREAD_LIMIT 1
6. Try deactivating plugins or themes temporarily
Some image optimization plugins can affect the upload of images to WordPress as they are directly tied to the media library. At time, security plugins can also cause issues with image upload. It is always a good idea to try deactivating recently activated plugins or themes if you are facing issues in uploading images to WordPress.
7. Try changing the PHP version of the website
This fix is especially applicable if you have recently updated WordPress from an extremely old version.
The Latest WordPress version of 5.4.1 would require PHP version 7.3 or greater. If you have recently updated from an extremely old version of WordPress with an old version of PHP, you may need to try changing the PHP version to 7.3 or greater to fix the issue.
8. Try disabling ModSecurity
Sometimes, the open-source firewall Modsecurity can cause interference with uploading images to WordPress. This can be fixed by disabling the offending ModSecurity rule or by disabling ModSecurity entirely for the account.
9. Try loading from a different browser
We have seen cases where the WordPress http error trigger while uploading images via Google chrome. In this case, as soon as we switch it to another browser like Mozilla Firefox, the issue immediately disappears.
This may be due to some browser compatibility issues and can be confirmed easily by uploading from a different browser.
10. Refresh the page
At times, it can be a temporary glitch. Just a page refresh may fix the issue here.
Conclusion
WordPress http error is a common error that is triggered while uploading images. In reality, it can be easily fixed with a systematic analysis approach. Today we discussed the possible reasons for this error message and how our Support Engineers fixed the issue each time.
0 Comments