You mean.. In one week time you have not found a solution to this? Have you even TRIED?
Anyway..
Use the new filename:
$newname = $userid.$target_path.$_FILES['uploadedfile']['name']
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$newname )){
With if(is_file($newname))
you can test beforehand whether a file with that name exists.