10-25-2007, 09:04 PM
|
#5 (permalink)
|
|
The Visitor
Join Date: Oct 2007
Posts: 4
Thanks: 0
|
Code:
define('DIRECTORY', 'images/');
function getImageName($szImage)
{
$filename = getImageName($_FILES['filetoupload']['name']);
$iIndex = 2;
if(!file_exists(DIRECTORY . $szImage))
{
return $szImage;
}
$aParts = explode('.', $szImage);
if(count($aParts) <= 1)
{
return $szImage;
}
$szExt = end($aParts);
$iCount = count($aParts);
$aParts[$iCount - 1] = $iIndex;
$aParts[$iCount] = $szExt;
do { $aParts[count($aParts) - 2] = $iIndex++; }
while(file_exists(DIRECTORY . implode('.', $aParts)));
return implode('.', $aParts);
}
|
|
|
|