Below is the code if you see the If file exists condition, i need to auto increment the values within ().
function onlyfilename($file) {
if(($pos = strrpos($file, '.')) !== false) {
return basename(substr($file, 0, $pos));
}
return basename($file);
}
function UploadFiles($ufile)
{
$file1_u = $ufile['tmp_name']; //Temporary Upload
$file1_name = $ufile['name']; //Get File Name
$file1_type = $ufile['type']; //Get File Type
$file1_size = $ufile['size']; //Get File Size
$time = time();
if ($file1_name != "")
{
if( $file1_size > 500000 ) $mesg = $mesg. "<li>Invalid image size, Allowed only 500KB.</li>";
if( $file1_type == "image/gif" )
{
$iCounter = 0 ;
if (file_exists("pictures/".$file1_name))
{
$iCounter++ ;
$sFileName = onlyfilename($file1_name) . '(' . $iCounter . ').' . $sExtension ;
}
else
{
copy("$file1_u", "pictures/{$file1_name}");
$smesg = "http://www.domainname.com/pictures/{$file1_name}";
}
}
if (isset($mesg)) return array($mesg, $smesg);
else return array($mesg, $smesg);
}
}