30

I am using WordPress 3.4.1 on Ubuntu 12.04 using Apache and PHP 5.3.X

When I login to the dashboard and add a new post. Then try uploading an image to set as a featured image, I get a red box with a message "HTTP Error".

I have read about people saying to not use the flash uploader and just use the browser uploader, but when I try that, I just get a 500 Internal Server Error.

I have tried adding AddType x-mapp-php5 .php at the top of my .htaccess file, with no luck in change.

Disabling ALL plugins had no effect. I tried a fresh install. No luck.

Update 10/17/2016 - If you're using custom roles or capabilities, please try using a native role/capabilities and try again.

Things to consider checking:

  • File ownership
  • File permissions
  • .htaccess configuration
  • PHP Version 7+
  • WordPress Current Version

If you're operating behind a proxy, be sure you have your proxy server timeouts configured correctly.

WordPress 3.4.1 Media Upload HTTP Error

1
  • What is the reasoning behind AddType x-mapp-php5 .php? That would seem to be very server specific. I would think it is more likely to break your site (ie. PHP) horribly (or do nothing if you are lucky) rather than improving anything?
    – MrWhite
    Commented Jan 1, 2018 at 17:29

6 Answers 6

27
+50

I put the following code into my functions.php file. It works!

add_filter( 'wp_image_editors', 'change_graphic_lib' );

function change_graphic_lib($array) {
  return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}

When this helps it is because it changes the PHP code module used for processing the uploaded image for use with WordPress.

This processing includes moving the image into the media library database and generating the different size images ("thumbnail", "medium", "large") that WordPress always wants available for themes to access.

It causes the "GD" module to be used, because it is first. In some server setups, the newer "Imagick" library isn't playing well with others for certain image scenarios, such as large pixel dimensions, so forcing the "GD" library to be used is a fix.

4
  • It's better to create a little plugin than putting it in the functions.php, because if you change the theme, you lose the code. And I'm sure you want this working after a theme change 😊 Commented Jan 15, 2018 at 11:43
  • 1
    +1 This worked for me when running in to this problem with an out-of-the-box WP 4.9.4 setup on a new HostGator account. @EliasNS noob here; what's the right way to make a little plugin for this? Commented Feb 27, 2018 at 1:26
  • @AndrewJanke, you could use a plugin 😅 es.wordpress.org/plugins/pluginception Commented Feb 27, 2018 at 11:07
  • "Imagick"? Not "ImageMagick"? Commented Jun 8, 2019 at 13:23
22

After troubleshooting with @Wyck in chat, we have narrowed to the underlying issue.

The issue was related to my server configuration not having the proper amount of memory allocated to Apache/PHP.

If anyone has this same problem, please try verifying that you have enough (64 MB+) server memory allocated to Apache/PHP in your server configuration settings. You can also add this to your wp-config.php file:

define('WP_MEMORY_LIMIT', '64MB');

If the above solution does not work, read the article Image/Media Uploader problems? for further troubleshooting.

Try adding one by one or all of the following .htaccess tweaks to the .htaccess file in the root directory of your WordPress installation.

Seriously, try one of each of the solutions below so you know which one did the trick. Don't just paste them all in your .htaccess file immediately.

Try this line:

AddType x-mapp-php5 .php

mod_security might be causing problems. Disable it to see if that is the problem. To do this, make an .htaccess file in your wp-admin directory. Add this to it:

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

If you're using access control based on authentication on your Webserver (often known as htpasswd, basic authentication, password protected directory or similar), WordPress is not able to handle it for Flash Uploader, Cron, and XMLRPC. Related files need to be excluded to work. Keep in mind that this might break your security considerations.

# Exclude the file upload and WordPress 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>

One final note: some have said that if using a lesser version of PHP 5.3.X you can try disabling PHP Safe Mode.

If you are running WordPress multi-site and are receiving HTTP errors or internal server errors, related to image uploading, please read Uploading Images to Multi-Site Causes Failure to HTTP Error) for other possible troubleshooting ideas and solutions.

3
  • ok ... good to know ... did you read that WP tries to allocate up to 256MB of ram so this define('WP_MEMORY_LIMIT', '64MB');should be larger if possible.
    – Damien
    Commented Jul 26, 2012 at 22:35
  • 1
    If you're using WP 4.1.1, the AddType x-mapp-php5 .php is no longer a viable solution as it forces the page to simply print the PHP code as plain text Commented Mar 27, 2015 at 6:02
  • 1
    Or add this to your sites config file if you are using nginx: client_max_body_size 128m;
    – Bent
    Commented Jun 28, 2015 at 16:00
4

I ran into the same error, when trying to upload media in wordpress. In Chrome, it shows up as a http: error; in Firefox, the error looks quite different. The web is full stories of people who have spent days to chase the bug (so have I :-( ). Solutions abound, but nobody explains why, at least not in a way that is consistent with the symptoms.

My tuppence worthy contribution: I noticed that the problem correlates with a segmentation fault signalled in the log file of apache2. That disturbs me, because it is difficult to diagnose.

Rebooting the entire server took away all symptoms and all of a sudden I could upload media again in Wordpress. Frustratingly, I have no clue as to why this occurs. The reboot effectively stopped me from any further research, and I will now have to wait (weeks? months?) for the problem to reappear. I hope this will help others in their quest for the cause of this problem. My wife is happy, though, because I can no longer spend nights chasing this problem...

1

I have resolved this issue by changing my owner from root to apache as below.

chown -R apache:apache /var/www/html/mydomain

And then I have change the permission of the wp-content/uploads/ to 775.

After that, I have tried to upload an image in the media. I was successful to upload the image.

0

I had the same issue. I tried various fixes, including changing the default image processor from PHP GD to ImageMagick using the Force Image Magick Plugin

This helped with the HTTP Error / the 500 error but thumbnails were no longer being generated. I then deactivated the plugin again and what then helped me was this answer on the question Looks like image resize is not working well. My PHP_MEMORY_LIMIT was set to 160MB which is the absolute maximum my hoster allows.

For uploading images this resulted in maximum possible dimensions of the image of around 6000 x 6000 px when using PHP GD and generating thumbnails. So it's important to not only check the file size but also the dimensions of the image. Uploading an image with higher dimensions resulted in an HTTP Error / error 500 even with small file sizes.

0

I've experienced such issue many times and solved by increasing memory_limit = 256M in php.ini OR adding define( 'WP_MEMORY_LIMIT', '256M' ); in wp-config.php file (*If needed you can increase memory more than 256M) most of the time.

Another possible solution could be giving permission to \wp-content\uploads\ folder; command: chmod -R 0755 wp-content\uploads\.

Hope it may help you too.

Not the answer you're looking for? Browse other questions tagged or ask your own question.