Resize image when uploading

This is my code:

<?php 

$target = “text/theatre”;
$target = $target . basename( $_FILES[‘uploaded’][‘name’]) ;
$ok=1;
if(move_uploaded_file($_FILES[‘uploaded’][‘tmp_name’], $target))
{
echo "The file “. basename( $_FILES[‘uploadedfile’][‘name’]). " has been uploaded”;
}
else {
echo “Sorry, there was a problem uploading your file.”;
}
?>

I would like to have the image resized to 360 X 300 upon upload. Could somebody please modify this code and repost it?