I'm not quite sure about the "gallery" script, but this is how I would have done with the photo script:
<?php
if(isset($_FILES['userfile']['tmp_name']))
{
$tmp = $_FILES['userfile']['tmp_name'];
$filename = $FILES['userfile']['name'];
$dir = "userphotos";
copy($tmp,"".$dir."/".$filename."") or die("Upload failed...");
echo "Upload Completed!";
}
else
{
echo "<form action='page.php' method='post' enctype='multipart/form-data'>
<input type='file' name='userfile'><p>
<input type='submit' value='Upload Photo'>
</form>";
}
?>