Fix extension handling.
git-svn-id: http://svn.automattic.com/wordpress/trunk@3377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d789b7005e
commit
39195303f1
|
@ -904,9 +904,19 @@ function wp_upload_bits($name, $type, $bits) {
|
|||
|
||||
$number = '';
|
||||
$filename = $name;
|
||||
while ( file_exists($upload['path'] . "/$filename") )
|
||||
$filename = str_replace("$number.$ext", ++$number . ".$ext", $filename);
|
||||
|
||||
$path_parts = pathinfo($filename);
|
||||
$ext = $path_parts['extension'];
|
||||
if ( empty($ext) )
|
||||
$ext = '';
|
||||
else
|
||||
$ext = ".$ext";
|
||||
while ( file_exists($upload['path'] . "/$filename") ) {
|
||||
if ( '' == "$number$ext" )
|
||||
$filename = $filename . ++$number . $ext;
|
||||
else
|
||||
$filename = str_replace("$number$ext", ++$number . $ext, $filename);
|
||||
}
|
||||
|
||||
$new_file = $upload['path'] . "/$filename";
|
||||
$ifp = @ fopen($new_file, 'wb');
|
||||
if ( ! $ifp )
|
||||
|
|
Loading…
Reference in New Issue