Media: Allow media_sideload_image() to work when the upload directory is a PHP Stream. Using copy() instead of rename() allows the function to work across different stream sources.

Props mattheu.
Fixes #29257


git-svn-id: https://develop.svn.wordpress.org/trunk@35579 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2015-11-09 00:44:01 +00:00
parent a62255ef65
commit 28ab6b9578

View File

@ -345,7 +345,9 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
if ( 'wp_handle_upload' === $action ) {
$move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file );
} else {
$move_new_file = @ rename( $file['tmp_name'], $new_file );
// use copy and unlink because rename breaks streams.
$move_new_file = @ copy( $file['tmp_name'], $new_file );
unlink( $file['tmp_name'] );
}
if ( false === $move_new_file ) {