Working with images

When added with images, the name is <name><format>, but should be <name>.<format>
Here is the piece of code responsible for this:

$dir='/bol/img/';
$format="jpeg";
$basename=basename($file);
$up_file=$dir.'.'.$basename;
echo ($up_file);
if (is_uploaded_file($_FILES['myfile']['tmp_name']))
{
$n=mt_rand(0,997);
$file_path=$dir.$n.$format;
if (!file_exists($file_path))
{

And one more question: how to correctly specify the path in $dir=’/bol/img/’;
And then he writes an error:

localhost/bol/img/.5VJE21LC.jpglocalhost/bol/img/791jpeg
Warning: move_uploaded_file(localhost/bol/img/791jpeg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\xampplite\htdocs\bol\admin\img.php on line 45
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampplite\tmp\php5AC3.tmp' to 'localhost/bol/img/791jpeg' in C:\xampplite\htdocs\bol\admin\img.php on line 45

If at all the full path of this folder is C:\xampplite\htdocs\bol\img


Answer 1, authority 100%

In the code (in the question which) you need to fix the line

$file_path=$dir.$n.$format;

to

$file_path=$dir.$n.".".$format;

Answer 2, authority 50%

Your code should look something like this:

$dir='/bol/img/';
if(isset($_FILES["myfile"]))
{
 $myfile = $_FILES["myfile"]["tmp_name"];
 $myfile_name = $dir.$_FILES["myfile"]["name"];
 if(move_uploaded_file($_FILES['myfile']['tmp_name'], $myfile_name))
   {
      echo "Upload ok";
   }
   else
   {
   echo "error Move file";
   }
}