Image won’t load

Wrote a script for loading an image into the database (the path to the database, the image in the directory). Everything is well written, only the picture does not appear in the catalog. Maybe I’m doing it wrong? Here is a piece of code responsible for loading….

if ($erro!=true){
$file=$_POST['myfile']['name'];
$dir='http://localhost/bol/img/';
$up_file=$dir.basename($file);
echo ($up_file);
if (is_uploaded_file($_FILES['myfile']['tmp_name']))
{
$n=mt_rand(0,997);
$file_path=$dir.$n.jpeg;
if (!file_exists($file_path))
{
$_FILES['myfile']['name']=$n.'.'.jpeg;
move_uploaded_file($_FILES['myfile']['tmp_name'],$dir.$_FILES['myfile']['name']);
$put=$dir.$_FILES['myfile']['name'];
}
dbConnect();
mysql_query("INSERT INTO image (put, nazv,opis,kto_kuda) VALUES ('{$put}','{$nazv}','{$opis}','{$kto_kuda}')") or die (mysql_error());
}}

The upload is via a form (<form method="post" enctype="multipart/form-data">)


Answer 1, authority 100%

$dir='http://localhost/bol/img/';

Why do you have the full path with the protocol?
Try changing to

$dir='./bol/img/';

Answer 2, authority 100%

Idaho37 is right. You are pointing the wrong path.
Here is a working example

include("core.php");
$panels = new panel;
echo '<a href="javascript:self.close()"> </a> ';
if($panels->checkauth())
{
    echo '<html>
        <body>
        <FORM ENCTYPE="multipart/form-data" ACTION="" METHOD=POST>
        <h4>   <br />   ( 1):</h4>
        <table><tr><td>  :</td><td>
        <input type="text" size="32" name="img_name" /></td></tr><tr><td>
        :</td><td>
        <INPUT NAME="myfile" TYPE="file"></td></tr><tr><td colspan=2 align=right>
        <INPUT TYPE="submit" VALUE=""></td></tr></table>
        </FORM>
        </body>
        </html>';
    if(isset($_FILES["myfile"]))
    {
        // Upload-
        $maxsize = 1024*1024*1; // 1  
        $valid_types =  array("image/png", "image/jpg", "image/gif", "image/jpeg");
        $dir="content_images/";
        // 
        $myfile = $_FILES["myfile"]["tmp_name"];
        $myfile_name = $dir.time()."_".$_FILES["myfile"]["name"];
        $myfile_size = $_FILES["myfile"]["size"];
        $myfile_type = $_FILES["myfile"]["type"];
        $error_flag = $_FILES["myfile"]["error"];
        if(strlen($_POST['img_name'])==0)
        $img_nm="No Name";
        else
        $img_nm=$_POST['img_name'];
        if($error_flag == 0)
        {
            if($maxsize>$myfile_size)
            {
                // if(in_array($myfile_type, $valid_types))
                // {
                    if(move_uploaded_file($_FILES['myfile']['tmp_name'], $myfile_name))
                    {
                            $image=new Imagick();
                            $image->readImage($myfile_name);
                            include("mysql_class.php");
                            $mysql = new db;
                            if($mysql->query_insert("INSERT INTO pr_image (u_id, image_url, image_name, adddate) VALUES('".$_SESSION['id']."', '".$myfile_name."', '".$img_nm."','".time()."')"))
                            {
                                print("  : ".$myfile_name." <br />");
                                print("MIME- : ".$myfile_type."<br>");
                                print(" : ".(round($myfile_size/1024))." kb <br><br>");
                                echo '<br /><img width=500px src="'.$myfile_name.'"';
                            }
                            else
                            {
                                unlink($myfile_name);
                                echo "<h2>  </h2>";
                            }
                    }
                    else
                    {
                        unlink($myfile);
                        echo "<h2> </h2>";
                    }
                // }
                // else
                // {
                    // unlink($myfile);
                    // echo "<h2>  </h2>";
                // }
            }
            else
                {
                    unlink($myfile);
                    echo "<h2>  1!</h2>";
                }
        }
    }
}
else
{
    echo "<font color=red> </font>";
}