4

In the media tab, upload of a valid image file results in display of "HTTP error".

Reload of the media tab shows that the image did upload and resize, though.

Browser debug tools show that on upload, browser is making a POST to wp-admin/async-upload.php. The server responds with a 500 error. The body of the response, though, is suspicious. The first part is a JSON structure. The JSON structure is immediately followed by an HTML document with the title "Wordpress Error" but an empty body.

Nothing going into the webserver (apache) error log and WP debug mode and increased PHP error/warning verbosity has not been helpful. Disabling all plugins had no effect on the error. Tried switching between GD and ImageMagick also with no success.

Relevant software versions:

  • Wordpress 4.2.2.
  • PHP 5.5.12-2ubuntu4.4.
  • Ubuntu Utopic

Any ideas on what might cause async-upload.php to return both JSON and an HTML error document and/or how I might further debug this?

  • Did you solve this? – Nicolai Jul 28 '15 at 8:00
  • I have tried out all suggestions with no success. Seems remarkable to me that WP fully forms the JSON response and then writes out an error document. Seems I'm going to have to do a deep dive on WP debugging to work this one out. – astletron Jul 28 '15 at 13:29
  • Too Bad, I was pretty sure that going through the list would solve it. – Nicolai Jul 28 '15 at 14:08
  • If any of the answer was helpful to you, then consider accepting it. See »What should I do when someone answers my question?« and/or »Why is voting important?«, more information about the WordPress Development model is available at the help center. – Nicolai Nov 9 '15 at 12:10
1

I had the same issue and did not find any information in my debug output.

It worked out, that DOING_AJAX was not defined (I don't know why).

Changing the beginning of async-upload.php from

if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) {
    define( 'DOING_AJAX', true );
}

to

define( 'DOING_AJAX', true );

worked for me. Maybe I will have a deeper look and find the real root cause.

0

Im my case (WP v5.0), it was PHP version problem (PHP v5.4). Switching to PHP v7.2 solved this problem.

0

In the wp-config.php file (wordpress's root folder) you have to enable the debug.

You have to set wp_debug to true.

Change define('WP_DEBUG', false); to define('WP_DEBUG', true);

Save the file and refresh the browser (I suggest you to use ctrl+f5).

You'll see all the errors.

1

This likely isn't exactly an issue caused by WordPress, but due to server configurations and/or settings. 500 errors are pretty generic and can have a variety of origins, so it is hard to give the one directive that will solve it. By the way, the returning of JSON and HTML seems to be common when this happens, not sure where and it gets mixed up, might be here . I'm fairly certain this happens due to some memory issue.

Although it likely has to do with the memory, I can't know for sure, because there isn't enough information available to be 100% certain. So here is a little, not necessarily comprehensive, check list for you to process:

  • memory limit - your PHP memory might be just on the verge of being not enough, increase it; put define( 'WP_MEMORY_LIMIT', '128MB' ); into wp-config.php
  • .htaccess - corruption/issue; check it; possibly back it up and regenerate it
  • PHP5 - some hosts had problems with that, although I haven't seen it some time; try putting AddType x-mapp-php5 .php into your .htaccess
  • file permissions - make sure they are correct, if you are unsure, then re-set them up with the correct ones; codex article: changing file permissions
  • folder permissions --
    • WP - check an if needed correct them; codex article: changing file permissions
    • server - sometimes there are e.g. problems with the permissions of the temporary upload folder
  • re-uploading WP core files - although that shouldn't be necessary if the last two steps are done correctly, but sometimes there are other corruptions, so it might be an additional step to take
  • apache setup - make sure your apache is set up correctly on your server, so to your needs and actual requirements; e.g. one common culprit seems to be mod_security
  • check WP custom code - so what you wrote or been installing via plug-ins; you know the routine, test by deactivating and/or switching to default theme and so on

All the list items are pretty much well known and documented, so you will, if needed, find more information out there.

Last but not least, much success!

  • 1
    I could fix it by disabling Apache's mod_reqtimeout. – Bernhard Aug 16 '18 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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