How to fix HTTP image upload error in WordPress

Published: 2021-09-20

Are you trying to upload images but encountering the HTTP upload error in WordPress? This is a very common WordPress error that regularly occurs on the platform when trying to upload images to the media library. Unlike other WordPress errors, this one gives no clue as to what is causing the error.

This makes it extremely difficult to track the issue and ultimately fix the issue. It can be extremely frustrating for newbies to the platform, but luckily you’re not the first person to run into the problem. Quick and easy solutions can be used to fix the error. Today I am going to show you how to fix HTTP image upload error in WordPress.

What causes the HTTP image upload error in WordPress?

The biggest problem with this error message is the lack of information it provides. There are no clues as to where or what is causing the error. This is because WordPress can’t figure out what’s causing the error, which is why it shows the generic HTTP error message. There are a few possibilities, but none of them take very long to fix.

The issue that is most likely is a temporary issue and I personally have experienced this issue quite a few times. If you’ve been inactive for too long while editing a page, you’ll be logged out and back in. I usually get the HTTP error when this occurs when trying to upload an image. Another major cause is the WordPress storage limit, not to be confused with the upload limit. When WordPress does not have enough memory to upload the image, this error can occur. Let’s take a look at some possible solutions to the problem.

How to fix HTTP image upload error in WordPress

Today I am going to show you how to fix HTTP image upload error in WordPress. You don’t need any additional plugins to fix this error, but you do need access to your website’s cPanel. The information is provided to you when you create an account with your web host. The lack of information makes it difficult to find a solution that will work for you, but these should be able to fix it for the vast majority of websites.

It’s only temporary

This is the most likely problem. I ran into this error quite a bit. If you start editing a page or post and remain idle for too long, WordPress will log you out. When you log back in everything seems fine but as soon as you try to upload an image the error will appear. It’s no big deal, leave the page or post you’re editing and go back and try uploading the image. That has always worked in my case.

There are other temporary causes to watch out for. When your website has an unexpected amount of traffic, the servers hosting your website can’t handle it all at once. This can be natural traffic or the result of a DDOS attack, and there are many ways to mitigate it. It will prioritize accepting requests from visitors rather than using resources to upload an image.

Either way, you need to give your site some time to catch up. Walk away from your work station for 10-20 minutes and check if the error is resolved. Make sure the traffic your website is getting is normal and if nothing gets fixed then you need to find the real problem.

WordPress storage limit

If the problem is not temporary, there is most likely a storage limit preventing the image from uploading. Keep in mind that this is not your upload limit, they are separate limits. By default, WordPress increases the memory limit to 64MB, but this isn’t always enough.

There are two ways to fix this: reduce the image size so it doesn’t take up as many resources, or increase the memory limit. Chances are that the second option sounds more appealing and is quite easy to do as it only requires one line of code.

Let’s start by logging into the cPanel and clicking on the File Manager option. The file manager gives you access to all files on your website.

Click on the File Manager option.

You need to find your wp-config.php file. Click on the public_html directory. Right-click the wp-config.php file and select the Edit option.

Select the Edit option.

A pop-up window will appear. This field warns you to back up your files before editing anything. This ensures that if something goes wrong, you can restore your website to the state it was in when it was working. Click the Edit button. A new tab will open containing all the code from the file.

Click the button "To edit".

Here we just need to add one line of code to increase your website storage limit. Like any code you add to the wp-config.php file, you should place the code above this line.[ht_message mstyle=“info“ title=““ show_icon=““ id=““ class=““ style=““ ]/* That’s all, stop editing! Have fun blogging. */[/ht_message]

The code below increases the memory limit to 256MB, which should be more than enough for any image-related memory issues on your website. Copy and paste the following line of code into your wp-config.php file:[ht_message mstyle=“info“ title=““ show_icon=““ id=““ class=““ style=““ ]define( ‘WP_MEMORY_LIMIT’ , ‘256M’ );[/ht_message]

After pasting the code into the wp-config.php file, click the “Save Changes” button to finish.

Click the button "save Changes".

Try uploading the image to see if the error has been resolved. If yes, congratulations, if not, I have another solution.

Change WordPress image library

If it’s not temporary or the memory limit wasn’t the issue, then it may very well be the library WordPress uses for images. WordPress comes with two libraries that you can use. These are the GD library and the Imagick library. The Imagick library is known to have memory issues that can cause this error. A simple solution is to switch from Imagick to the GD library.

In the file manager, locate your functions.php file and copy and paste the following code into the file:[ht_message mstyle=“info“ title=““ show_icon=““ id=““ class=““ style=““ ]function change_library_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’, ‘change_library_to_gd’ );[/ht_message]

This should solve the problem if the Imagick library was to blame. If this is not the case, you can always delete this code.

Always fix WordPress errors

Getting error messages is common and it can be frustrating, but it will happen. The faster you react and fix the error message, the faster your website will run smoothly again. Downtime on a website is a loss of income. Visitors can’t see ads or make purchases on your site. All downtime is bad downtime and needs to be fixed quickly.

Luckily, WordPress is the most used website development platform in the world. This means that for every error message you encounter, there are tons of solutions, making fixing it as easy as Googling.

Was the bug temporary for you? What caused the HTTP image upload error for your website?

Previous post PHP upload size for Strato web packages
Next post Strato: File size limit for files created using PHP