I don't see where you ever define $uploaded_type or $uploaded_size, so of course they wouldn't work. you can use the information within $_FILES to define one of these variables:
PHP Code:
$uploaded_size = $_FILES['uploaded']['size'];
however, the "type" passed in the $_FILES array is just a mimetype sent by the browser. this means that you shouldn't take it for granted, and instead you can get the actual file extension of the file to check whether or not it's "valid."
PHP Code:
$extension = pathinfo($_FILES['uploaded']['name'], PATHINFO_EXTENSION);
$bad_extensions = array("php", "cgi", "html", "mp3", "exe");
if(in_array(strtolower($extension), $bad_extensions)){
echo "bad extension";
}else{
//move your file
}
you're also referencing two different $_FILES in your script; if your form's "file" input is named "uploaded," make sure every reference to $_FILES is "uploaded" (not "uploadedfile" like you've done at least once).
and yes, you can check if a file already exists by using the function file_exists().
PHP Code:
if(file_exists($newpath)){
echo "filename already exists.";
}else{
//move file
}
a better way of doing this would be to tack a number onto the end of the file name, in a loop, until that file does not exist. this is only better if you'd rather it didn't "cancel."