wp image http error

I believe many people encountered this HTTP error when uploading an image or other files to WordPress using built-in media uploader. In this article, we will show you how to fix the image upload HTTP error in WordPress.

Check also: How to reset WordPress login password

So Let’s start

Temporary upload HTTP error

First, you try to upload your image after few minutes. Sometimes this error is caused by heavy traffic and low server resources, which are automatically fixed on most hosting servers.

If it doesn’t work, Then you may want to try uploading a different image or different format file. If the other’s file uploaded successfully, then try to compress your original image file and retry uploading.

If still same HTTP error, then this means that the error is not caused by a temporary glitch.

Plugin conflict

Some WordPress plugin triggers this HTTP error. If the problem appears after installing a plugin, Disable one plugin at a time. Clear your cache and browser history then retry to upload your image.

Using .htaccess method

  • Go to your Cpanel
  • Using the file manager, navigate to your WordPress site’s root directory.
  • Locate and open the .htaccess file for editing.
  • Add the following line of code at the top of the file:
SetEnv MAGICK_THREAD_LIMIT 1
  • Save the changes to the .htaccess file.

Increase PHP WordPress Memory Limit

The most common cause of this error is limit WordPress memory. To fix this issue, you need to increase the amount of memory PHP can use on your server.

You can fix this by adding the following code to your wp-config.php file.

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

This code increases the WordPress memory limit up to 96MB, which would be enough to fix any memory limit issues. This code may not work if your host doesn’t allow you to increase the PHP memory limit, So I suggest you contact your hosting support and ask them to change the PHP memory limit for you.

Change Image Editor PHP Module

WordPress uses two PHP modules to handle images. These modules are called GD Library and Imagick. WordPress uses one of them depending on which one is available.

Sometimes, Imagick is known to often run into memory issues causing the HTTP error during image uploads. To fix this issue, you can make the GD Library your default image editor.

You fix this issue by simply adding this following code to your theme’s functions.php file

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 adding this code, you can retry uploading image files using the media uploader. If this doesn’t solve the issue, then you can remove this code and try other methods described in this article.

 

Disable ModSecurity

If your server has installed mod_security, and it might be causing problems. For fix HTTP error try to disable mod_security. To do this, make a .htaccess file in your wp-admin directory and add the following code to it:

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

That will disable mod_security for the upload file in the wp-admin.

Note: Remove this if it’s causing any error on your server.

 

Also, if you need my help click here

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here