Show a relative path in an upload error message.
git-svn-id: http://core.svn.wordpress.org/trunk@24463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e27d41d8e7
commit
be01fce99f
|
@ -328,8 +328,14 @@ function wp_handle_upload( &$file, $overrides = false, $time = null ) {
|
|||
|
||||
// Move the file to the uploads dir
|
||||
$new_file = $uploads['path'] . "/$filename";
|
||||
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
|
||||
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
|
||||
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {
|
||||
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
|
||||
$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
|
||||
else
|
||||
$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
|
||||
|
||||
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
|
||||
}
|
||||
|
||||
// Set correct file permissions
|
||||
$stat = stat( dirname( $new_file ));
|
||||
|
@ -452,7 +458,11 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
|
|||
// Move the file to the uploads dir
|
||||
$new_file = $uploads['path'] . "/$filename";
|
||||
if ( false === @ rename( $file['tmp_name'], $new_file ) ) {
|
||||
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
|
||||
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
|
||||
$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
|
||||
else
|
||||
$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
|
||||
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
|
||||
}
|
||||
|
||||
// Set correct file permissions
|
||||
|
|
Loading…
Reference in New Issue