Http Error Uploading Image – WordPress

Http error uploading image wordpress

Are you seeing the ‘Http error uploading image’ or ‘Unable to create directory wp-content/uploads/[current year]/[current month]. Is its parent directory writable by the server?’ message in WordPress?
These are both very common errors, especially on new installs. Luckily, the fix is a breeze – so stay tuned to learn how to get that image uploaded successfully.

Solution #1: Check the Directory Permissions

You can set the permissions necessary for WordPress by running the following commands in the root directory of your WP install:

sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php

This will ensure that your folders have the right permissions, which is required for image uploading to work correctly. Once you apply the permissions, test and see if you’re able to upload the image as intended. If you’re interested in learning more about filesystem permissions and why WordPress uses these in particular, Benjamin Intal has a great article with extensive info here.

Proceed to the next step if your issue is not resolved.

Solution #2: Raise the WordPress Memory Limit

If you’ve confirmed that your directory permissions are correct from the first solution, the next thing to try is raising the memory limit in WordPress to allow for larger files to be uploaded. WordPress may be running out of memory on the upload and throwing the error for that reason. To check, open your wp-config.php in the root directory of your WordPress site, and search for ‘WP_MEMORY_LIMIT’. If you don’t find it, add the following line:

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

If that line was already present, try raising it to something higher. The ‘M’ stands for Megabytes, and it’s extremely unlikely that any image you’re trying to upload ever exceed 256 megabytes, so this is a great limit to raise it to. If you’re uploading videos rather than images, however, note that you may need to raise this limit even higher.

Save the wp-config.php and retry your upload. Check if your http error uploading image WordPress is resolved.

Hopefully the new expanded memory limit solved your problem. If it did, let me know about it in the comments! If not, proceed to Solution #3 for the next fix.

Solution #3: Change the Image Library

PHP has two different options for image processing library – Imagick or GD Library. Either library will generally work fine and play nice with WordPress, but on some hosts Imagick may run into memory issues. In this fix, we set GD Library as the default to see if there’s a problem with Imagick on your web host.

Open your theme’s functions.php file located in wp-content/[your_theme_here]/functions.php and add the following snippet to the end:

function image_editor_default_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', 'image_editor_default_gd' );

Save your changes and try uploading the image again. With any luck, GD Library did the trick! Let us know in the comments if this worked for your http error uploading image WordPress.

Leave a comment

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