$target = $target . basename( $_FILES['photo']['name']);
you have on the top, move it as
$target = "../files/photos/"
//Find file extension of photo
$newfilename = "thisnameexactly";
$ext = end(explode('.', $_FILES['photo']['name']));
$newfilename = $newfilename . "." . $ext;
$target = $target . $newfilename;
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)){
echo "image successfully uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}