Make WordPress Core


Ignore:
Timestamp:
06/21/2013 02:29:26 AM (11 years ago)
Author:
nacin
Message:

Show a relative path in an upload error message.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r23739 r24463  
    329329    // Move the file to the uploads dir
    330330    $new_file = $uploads['path'] . "/$filename";
    331     if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
    332         return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
     331    if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {
     332        if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
     333            $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
     334        else
     335            $error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
     336
     337        return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
     338    }
    333339
    334340    // Set correct file permissions
     
    453459    $new_file = $uploads['path'] . "/$filename";
    454460    if ( false === @ rename( $file['tmp_name'], $new_file ) ) {
    455         return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
     461        if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
     462            $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
     463        else
     464            $error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
     465        return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) );
    456466    }
    457467
Note: See TracChangeset for help on using the changeset viewer.