Code:
if ($_FILES['imagefile']['type'] == "image/jpg"){
copy ($_FILES['imagefile']['tmp_name'], "files/".$_FILES['imagefile']['name'])
or die ("Could not copy");
This is something i made a long time back. See if it works for you, the code is self explanatory.