This question already has an answer here:
I want to rename the file while uploading to avoid overwriting of files, I have following code, Please suggest code to avoid overwriting.
$path = "admin/uploads/resume/";
if (!file_exists($path))
mkdir($path, 0, true);
$img_name = $_FILES['file']['name'];
$img_tmp_name = $_FILES['file']['tmp_name'];
$img_path = $img_name;
move_uploaded_file($img_tmp_name, "admin/uploads/resume/" . $img_path);
$img_name = $_FILES['file']['name'];
</div>