How to Fix the HTTP Image Upload Error in WordPress

How to Fix the HTTP Image Upload Error in WordPress

Last modified: November 4, 2020

FAQ
Cloudways

Are you getting the HTTP error while trying to upload media to your WordPress website? This normally happens when using the inbuilt media uploader. This article shows you how you can fix the error on your site, without the need to contact or incur the expense of a website developer.

Show More

* This button will show the rest of the post and open up an offer from a vendor

The Cause of HTTP Error During Media Upload in WordPress

This error can be caused by a number of issues. But WordPress can’t tell you what the problem is. That is why it displays a generic HTTP error message.

The biggest problem with this error, is that you have no clue as to where the problem might be. Therefore, you might have to try numerous solutions in order to find the cause and fix the error.

So, here are some of the basic ones that you should be trying.

1. Temporary Issue

First thing you should try is to ensure that the problem is not a temporary problem. Wait a few minutes and then try to re-upload the image file again. This error can sometimes happen because there is a high level of traffic or low server resources. These are normally fixed through your hosting provider without you knowing about it.

If the problem doesn’t work. Then try another file image. If that doesn’t upload successfully, try saving the page/post you’re working on and trying again. This can sometimes be the problem. You might find that there was a time-out issue and you were logged off WordPress without seeing the log back in screen again.

Final option might be to save the image in a different format. For example, change any jpeg to png. This can be done using any image editing software. After changing the format, try to re-upload the image.

2. WordPress Memory Limit

A common cause of the error is that there is a lack of memory for WordPress. Fixing this can be really simple. All you need to do is to add this following line of code to your wp-config.php file.

define( 'WP_MEMORY_LIMIT', '256M' );

This can be done through an FTP software program. This little line of code will increase the WordPress memory to 256MB. Usually this will fix all memory issues on your website. You can also increase the 512MB, though that is usually unnecessary.

3. Change The Image Editor Library Used

WordPress runs on PHP. This uses two modules to handle images. The modules are GD Library and Imagick. Depending on which one is available, WordPress can choose to use either one. However, Imagick can run into some memory issues that can cause the HTTP error. Therefore, you need to make the GD Library the default image editor.

So, open up your functions.php file using the FTP client. Then you add the following code:

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' );

After you’ve added the code and saved the file back to your WordPress files, you need to check that it has worked. You can remove this code if it hasn’t worked.

4. The .htaccess Method

If you’re on a shared hosting plan, then your provider might limit Imagick’s functions. It can limit the ability of the software to use multiple threads. This is for faster processing. However, it can also cause the HTTP error when you’re uploading images to your website.

To fix this, add this code to the .htaccess file:

SetEnv MAGICK_THREAD_LIMIT 1

This code will just limit Imagick to use a single thread. Therefore, it won’t attempt to use two or more threads that are causing the issue.

Final Word: How to Fix the HTTP Image Upload Error in WordPress

Want to fix the HTTP Image Upload Error in WordPress? Then follow the four options above. There is no need to hire a developer to help.

Recap:
Save 4 Later
Email liked links to yourself