I'm setting up a clone of a multisite network to act as a staging environment. Everything is rendering fine, I can log in to the admin, so far so good. When I try to upload a media item, async-upload.php reports success, but the file itself is not placed in the uploads directory and the raw file URL 404s...

Uploads are working correctly in the live environment. I've completed the steps here and here to create the staging network. Full response from async-upload.php is here.

I recursively set permissions on wp-content/uploads to 755 for directories, and ownership on that directory is set to apache:www, just like the live environment. And if I set permissions to something that don't work, WordPress displays an error on upload attempts. So I'm pretty sure I can rule out a permissions issue.

Also, this is on a server running SELinux, but watching the audit log I'm not seeing any security-context failures. Not sure if there's somewhere else these failures might be registering though.

Yes, this happens when I disable all plugins and activate the TwentyFifteen theme (which is the latest stock theme installed).

Update:

I have updated functions.php with the following debug filters:

add_action('init', function() {
  if($_FILES) {
    error_log(var_export($_FILES), true);
  }
});
add_filter('wp_handle_upload', function($file) {
  foreach($_FILES as $key => $_upload) {
    $tmps = glob($_upload['tmp_name'].'/*');
    error_log(var_export($tmps), true);
  }
  error_log(var_export($file), true);
  return $file;
});

The output to debug.log is:

[01-Feb-2017 16:25:43 UTC]  array (
   'async-upload' => 
   array (
     'name' => 'Screenshot 2017-02-01 07.22.13.png',
     'type' => 'image/png',
     'tmp_name' => '/tmp/phphEGrpX',
     'error' => 0,
     'size' => 71042,
   ),
 )
[01-Feb-2017 16:25:43 UTC]  array (
 )
[01-Feb-2017 16:25:43 UTC]  array (
   'file' => '/var/www/wp-content/uploads//2017/02/Screenshot-2017-02-01-07.22.13-9.png',
   'url' => 'http://staging.example.com/wp-content/uploads/2017/02/Screenshot-2017-02-01-07.22.13-9.png',
   'type' => 'image/png',
 )

Pretty sure that's not normal? Shouldn't the file at least exist in the /tmp directory?

  • What happens when you simply transfer a file directly into the uploads directory? Does the URL work? – CK MacLeod Jan 19 '17 at 23:43
  • @CKMacLeod, yes, once I set the permissions properly. The ssh user and the apache user are different, and the security contexts are also different by default because I can't scp directly into the uploads folder. But once I fix those two things manually I can view the image in the browser just fine. – acobster Jan 20 '17 at 1:18

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.