Fix extension handling.
git-svn-id: https://develop.svn.wordpress.org/trunk@3377 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a3cb29233b
commit
164371f70f
|
@ -904,8 +904,18 @@ 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');
|
||||
|
|
Loading…
Reference in New Issue