Make WordPress Core


Ignore:
Timestamp:
12/16/2007 09:34:48 PM (16 years ago)
Author:
ryan
Message:

Import file attachments. Props tellyworth. fixes #5466

File:
1 edited

Legend:

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

    r6116 r6390  
    148148        return $upload_error_handler( $file, $uploads['error'] );
    149149
    150     // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
    151     if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) {
    152         $filename = $unique_filename_callback( $uploads['path'], $file['name'] );
    153     } else {
    154         $number = '';
    155         $filename = str_replace( '#', '_', $file['name'] );
    156         $filename = str_replace( array( '\\', "'" ), '', $filename );
    157         if ( empty( $ext) )
    158             $ext = '';
    159         else
    160             $ext = ".$ext";
    161         while ( file_exists( $uploads['path'] . "/$filename" ) ) {
    162             if ( '' == "$number$ext" )
    163                 $filename = $filename . ++$number . $ext;
    164             else
    165                 $filename = str_replace( "$number$ext", ++$number . $ext, $filename );
    166         }
    167         $filename = str_replace( $ext, '', $filename );
    168         $filename = sanitize_title_with_dashes( $filename ) . $ext;
    169     }
     150    $filename = wp_unique_filename( $uploads['path'], $file['name'], $ext, $unique_filename_callback );
    170151
    171152    // Move the file to the uploads dir
Note: See TracChangeset for help on using the changeset viewer.