Share on

Table of Contents

profile-pic (1)
Mansoor Ahmad
November 6, 2024

How To Fix HTTP Error When Uploading Images to WordPress

When uploading a file to WordPress you will often get the error ‘HTTP error’ file cannot be uploaded. The error is frustrating and it often has no solution. You try once and the file doesn’t upload and then you try again and it magically uploads, this happens a lot, no?

At least it happens to me a lot and in this article, I am going to discuss some of the ways by which you can easily fix the HTTP error problem when uploading a file to WordPress.

We will be covering 10 different solutions that can help you easily fix the WordPress HTTP error problem by yourself. Let’s learn why HTTP error occurs 

When you are uploading a pdf file, a video, or an image file, you will get the HTTP error on WordPress if the limit is small. There are many more issues for the HTTP error in WordPress and that’s what we are going to fix in this article.

Reasons HTTP Error Occurs

  1. Your internet has a higher ping and you are not able to upload the file completely.
  2. You are using a browser that doesn’t has cookies enabled
  3. You are using a VPN server and WordPress thinks it is suspicious
  4. Your WordPress cache is not cleaned and rewriting is becoming a problem for WordPress
  5. You have certain plugins of WordPress that are not allowing it to upload the file
  6. Your WordPress memory limit is too small and you can’t upload bigger file sizes
  7. You are using an old PHP version that is becoming a hurdle in file uploading
  8. The file is too big to be loaded. You need to reduce the file size
  9. There is a security problem with the file and WordPress considers it malicious
  10. The filename is not accepted by WordPress. This type of problem is solved by just changing the file name.

Now that we know all about the WordPress HTTP error when uploading a file, let’s learn what are some of the ways that you can use to fix these WordPress errors.

Easy Ways to Fix WordPress HTTP Error

Here is a list of the solutions that can help you remove the WordPress HTTP error problem once and for all. If one of the solutions doesn’t solve your problem, then move to the second one because one of these methods will be able to fix your problem for sure. 

Now, let’s start with the solution one. 

Solution 1: Identify the WordPress HTTP Error

Are you sure that you are connected to the internet? Are you signed in to your WordPress website? Is the server still up and running? Is the file that you are uploading to WordPress following the right naming convention? Is the file size too high on WordPress? 

These are just some of the questions that you need to ask yourself when you see the HTTP error on your WordPress website.

The purpose of the first solution is to actually identify if these all minor issues are not the reason for the HTTP error. Because 90 percent of the time, it is any one of these issues that are becoming the reason.

A good number of users have found that adding apostrophes in the file name caused the HTTP error on WordPress. So, do that. 

If that doesn’t solve the problem, then move to the second solution.

Solution 2: Is Your Browser the Problem?

Many users have reported that a WordPress HTTP error occurs when they are using a specific browser. For example, the error only appears when you are using a chrome browser and doesn’t occur when you are using Opera or Firefox browsers. 

So, try to change your browser and see if that can make a difference. If you are able to upload the file to your WordPress website by just changing the browser then perhaps the browser is having some issues. You can change the second browser for uploading documents.

Solution 3: Deactivate Problematic Plugins 

When uploading images to WordPress, the HTTP error usually occurs when you have an image optimization plugin available. What the plugin does is that when you are uploading the image, it automatically resizes it. Since the resized image is not yet saved, WordPress doesn’t accept it on the server and an HTTP error shows up.

The problem is the plugin because it is automatically resizing uploaded images. The solution to this problem is to simply disable the plugin or disable the functionality in the plugin that automatically resizes the images. That is it. It is as simple as deactivating the plugin for the time being.

Now try to reupload the image to the WordPress website. In most cases, you will see that the image can now be uploaded to WordPress without any issue. If the file still doesn’t upload to WordPress and you get the HTTP error, then you can move to the next solution.

Solution 4: Increase WordPress Memory Limit

A common cause of the HTTP error in WordPress is a lack of memory. It can also result in many other issues such as the 503 services unavailable error. Fixing low memory is a matter of adding the following line to your wp-config.php file:

Another cause of HTTP error in WordPress websites is the lack of memory or the memory limit. Most hosting solutions have a memory limit from the start that disallows files more than a specific size to be uploaded to WordPress. This problem can be solved by changing the WordPress size limit on the WP_config.php file.

Here is what you need to do to increase the WordPress memory limit.

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

The code should be pasted in the WP_config.php file. What it does is to increase the PHP memory limit to 256MBs. You should also make sure to confirm the maximum available memory limit in the PHP info file. 

Now save the wp_config file and then try again uploading the file/image to your WordPress website. In most cases, your HTTP error problem will disappear. If it doesn’t, move to the next step.

Solution 5: Make GD Library Your Default Image Editor

Do you know that WordPress comes with two image editors out of the box? The image editors are used to process images but one of these image editors, Imagick often exhausts memory limits and this is the reason for the HTTP error. 

So, you just have to disable the Imagick image editor and replace it with the GD library image editor as your default one.

Here is how to get it done. 

Note: make sure to backup your Functions.php file before you make any changes to it.

Now add the following code to the WordPress functions.php file.

function hs_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', 'hs_image_editor_default_to_gd' );

Now try uploading the file to the WordPress site and see if it uploads. If it doesn’t upload, remove the code from your WordPress functions.php file, and then move to the next solution.

Solution 6: Editing .htaccess

Another method to solve the HTTP error is through the .htaccess file. For this process to work flawlessly, you will need to add the following code to the .htaccess file.

SetEnv MAGICK_THREAD_LIMIT 1

If a WordPress file is executing multiple tasks, the magick threat limits the number of tasks the image magick tool is executing on WordPress. What this does is that it won’t resize your images when they are uploaded, removing the HTTP error from the file when uploaded.

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

Another way to test the above snippet is with the following code. If the Magick thread limit code doesn’t work out then you can use the filter engine code in your .htaccess file. What we are doing is that we are disabling the mod_security firewall. It is an open-source firewall that is available by default on all hosting servers. You are turning it off so that the file can be uploaded without any issues.

The purpose of both the scripts is the same and that is to fix the HTTP error problem. If one doesn’t work, feel free to use the second one. If the second one doesn’t work, you can use the following code:

# Exclude the file upload and WP CRON scripts from authentication
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
Order allow, deny
Allow from all
Deny from none
</FilesMatch>

Try each one individually. One of them will work and your HTTP error problem will be solved. 

Solution 7: Is Theme the Problem?

In rare cases, the problem occurs because of a theme that is not accepting the uploaded images. The solution to this problem is to simply change the theme back to the default WordPress theme. In your case, it would be the WordPress theme Twenty Twentyone. 

It is always better to start with a backup of your website before you move to the default theme. In case the website gets corrupt, you can get it restored through the backup you created.

Solution 8: Check Your PHP Version

You should check what PHP version you are using for your website. If your website is hosted on a server that has an old version of PHP installed, move to the new one. Here is a complete article on how to change your PHP version through cPanel. You can also change the PHP version if you are still using the old version. 

PHP displays its latest version on its website. You can check the website here

Once you have the latest version of PHP installed on your server, try uploading the file again. You should be able to upload the file without any issues.

If you still face some issues, then you can move to the next solution.

Solution 9: Clear Your Caches

The last thing you need to do is to clear your browser cache. Although browser cache doesn’t really affect your website file uploading, it can still make a difference. So, try to clear the cache and then try again. In this way, you will be able to easily upload to your website without getting the HTTP file error.

Solution 10: Use Add from Server Plugin

The Add From Server plugin is not in active development but it can be a good workaround if you are not sure how to get around the HTTP error once and for all. With the Add from Server plugin, you can directly add the file using SFTP. It will bypass the WordPress media library and add the file to your desired location. 

One problem is that the Add from Server Plugin is no longer in active development so you will not be able to get any support if the plugin stops working. For now, the plugin has 100,000 active installs. It is already in active development so you can rest assured that you won’t be facing any problem when using it.

Bottom-line

Removing the HTTP error from your website is not really a problem. What you need to do is to just test the solutions that we have offered. Try each one of them and one of them will help you remove the HTTP error for good. If you are still unsure how to fix the error from your WordPress website even after trying all these methods, you can get in touch with our WordPress experts. All our experts are certified and can help you fix your website issues within minutes.

Mansoor Ahmad

Mansoor Ahmad is a web developer and WordPress enthusiast. He has been building websites with WordPress since 2013. He is passionate about teaching and writing about WordPress and helping fellow web creators build better websites.

How To Integrate Infobip with JetFormBuilder for SMS OTP Verification

https://youtu.be/m-wPLdQvHOo Infobip is not your most popular platform for SMS delivery compared to the others and that is why there is quite little support in terms of integration with WordPress

Why is WordPress Slow – 10 Common Reasons on Most Sites

Your WordPress website is your business hub. If it is slow, you are getting less business from the website. Less business activity means less profit. You don’t want that, do

Four Ways to Redirect www to Non-www of WordPress Website

People rarely use the ‘www’ standard for writing URLs today. Instead, they prefer to write the URL’s name and its domain type in search engines and press enter.  Google treats