Make WordPress Core

Changeset 3377


Ignore:
Timestamp:
12/29/2005 01:46:32 AM (19 years ago)
Author:
ryan
Message:

Fix extension handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r3376 r3377  
    905905    $number = '';
    906906    $filename = $name;
    907     while ( file_exists($upload['path'] . "/$filename") )
    908         $filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
    909 
     907    $path_parts = pathinfo($filename);
     908    $ext = $path_parts['extension'];
     909    if ( empty($ext) )
     910        $ext = '';
     911    else
     912        $ext = ".$ext";
     913    while ( file_exists($upload['path'] . "/$filename") ) {
     914        if ( '' == "$number$ext" )
     915            $filename = $filename . ++$number . $ext;
     916        else
     917            $filename = str_replace("$number$ext", ++$number . $ext, $filename);
     918    }
     919       
    910920    $new_file = $upload['path'] . "/$filename";
    911921    $ifp = @ fopen($new_file, 'wb');
Note: See TracChangeset for help on using the changeset viewer.