gallery script

Hello, here is the upload script for a simple gallery page. I can’t figure out the directory.

<?php
//  upload  
if(isset($_FILES["myfile"])) 
{ 
$myfile = $_FILES["myfile"]["tmp_name"]; 
$myfile_name = $_FILES["myfile"]["name"]; 
$myfile_size = $_FILES["myfile"]["size"]; 
$myfile_type = $_FILES["myfile"]["type"]; 
$error_flag = $_FILES["myfile"]["error"];
//     
if($error_flag == 0) 
{
$f_thum="./gallery/thum_" . $myfile_name;
print("     (  ): ".$myfile."<br>"); 
print("    : ".$myfile_name."<br>");
print("   : ".$f."<br>");
print(" thumb-  : ".$f_thum."<br>");
print("MIME- : ".$myfile_type."<br>"); 
print(" : ".$myfile_size."<br><br>");
//     512 
if ($myfile_size > 512*1024) die('   512 !     ');
//  
copy($myfile,"./gallery/$myfile_name");
//  thumb
function imageresize($outfile,$infile,$neww,$newh,$quality) {
    $im=imagecreatefromjpeg($infile); 
    $im1=imagecreatetruecolor($neww,$newh); 
    imagecopyresampled($im1,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
    imagejpeg($im1,$outfile,$quality); 
    imagedestroy($im); 
    imagedestroy($im1); 
}
//    160100,  JPEG 75
imageresize($f_thum,"./gallery/$myfile_name",160,100,75);
} 
}
else 
{
    //  
    echo file_get_contents('gallery_form.html');
}
?>
    
?php
$dir = "./gallery";
$N = 3;         //    
echo "<h1></h1><p><table width=100$ cols=$N>";
$i = 0;         //  
//     gallery   images
$images = scandir($dir);
//    
foreach ($images as $k=>$v)
{
//        
if (strpos($v,"thum_")!==false)
    {
        if ($i % $N == 0) echo "<tr>";
        echo "<td>";
        $image = substr($v, 5);    
        echo "<a target=_blank href=\"$dir//$image\"><img border=0 src=\"$dir//$v\"></a>";
//      text       
echo "<form action=\"router.php\" method=post>
<input name=del type=text readonly=true value=\"$image\" />
<input name=del type=text readonly=true value=\"$v\" />
<input name=submit type=submit value=delete />
</form>";
            echo "</td>";
            $i++;
        }
}
echo "</table>";
echo file_get_contents('gallery_form.html');
?>

Answer 1, authority 100%

copy($myfile,"localhost/gallery/$myfile_name");
// :
copy($myfile,$_SERVER['DOCUMENT_ROOT']."/gallery/$myfile_name");
//     
 localhost  $_SERVER['DOCUMENT_ROOT']