PHP ROUTE

How to Fix HTTP Error When Uploading Image to WordPress

Are you having trouble uploading images to your WordPress website? Some people get HTTP error when they try to upload images and after a check up we can come up with several fixes for this. It can be caused by several reasons and here are the list of things you can do to fix HTTP error you get when uploading images.

Increase Upload file size limit for Your WordPress Site

WordPress by default have a limit on the file size you can upload. Sometime cheap web host set it to very low and that can trigger that HTTP error. Please check if its below 2 MB or or similar. You should make it anywhere between 64 MB to 256 MB. But remember this, you may increase the upload limit but you should not use very large images to your WordPress. Always keep it very as low as possible but keep a decent resolution. To change this upload limit you need to visit your file manager and then root folder of your WordPress installation. Find wp-config.php file and open it with an editor then add this line to this file.

define(‘WP_MEMORY_LIMIT’, ’64MB’);

Increase upload size limit in your php.ini file

Sometime it can be limited by using php configuration itself so to increase it you need visit your cpanel and open php configuration. You can see a setting for memory_limit = 256M so you can easily change it to whatever you want. Some host don’t allow changing this php.ini by customers so in that case you may need to contact your hosting provider and ask them to increase the limit.

Editing the .htaccess File For MAGICK_THREAD_LIMIT

Using the file manager visit your WordPress sites root directory. Now you need to locate .htaccess file but remember most of the time .htaccess files are hidden by default and you may need to unhide this before doing this.

Now add this following line of code at the top of the file.

SetEnv MAGICK_THREAD_LIMIT 1

Now you can save changes to the .htaccess file.

Changing the MOD Security

If your web-server may have mod security enabled and it might also cause problems. To disable it you may need to make a .htaccess file in wp-admin folder and add the following code to it.

<IfModule mod_security.c>

SecFilterEngine Off

SecFilterScanPOST Off

</IfModule>

Change Image Editor Library Used by WordPress

Images are handled buy two modules these are called GD library and Imagick. And all images are processed by any one of them selected by WordPress. Sometimes Imagick can cause several memory issues and make http error during uploads tho fix this you need to change your default image editor to GD Library.

To make this happen you need to add the following code to your themes functions.php or you can make site specific plugin for your WordPress site.

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

Changing the File Directory Permission

If all these things doesn’t solve your problem then you may have problems with your File and Folder permission. Most web hosts use Linux as a file system and wrong folder permission can mess up the the uploading files.

Most file permissions for WordPress should be set at 755. This allows WordPress to add new files to a directory. Check your uploads directory and set the permission to 755 including all  sub directory.

  1. Owner – Read, Write, Execute (7)
  2. Group – Read, Execute (5)
  3. Public – Read, Execute (5)

We hope this guide fixed your WordPress site but if not then please ask for it in the comments. The HTTP error is very surprising error to encounter.

Have questions or confused about something WordPress Related? Join Our Discord Server & ask a Question

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top