$filename = fileExists(FILE_PATH.$_FILES['photo_file']['name']);
function fileExists($file){
if(!file_exists($file)){
$path_parts = pathinfo($file);
$filename = $path_parts['filename'].".".$path_parts['extension'];
return $filename;
}else{
$path_parts = pathinfo($file);
$filename = rand(100,1000).$path_parts['filename'].".".$path_parts['extension'];
$file = $path_parts['dirname']."/".$filename;
return fileExists($file);
}
}
function fileExists($file){
if(!file_exists($file)){
$path_parts = pathinfo($file);
$filename = $path_parts['filename'].".".$path_parts['extension'];
return $filename;
}else{
$path_parts = pathinfo($file);
$filename = rand(100,1000).$path_parts['filename'].".".$path_parts['extension'];
$file = $path_parts['dirname']."/".$filename;
return fileExists($file);
}
}