Php alert doesn't work : I am trying to pop up an alert in html with php if the user hasn't upload a file in input element.

The source code in index.php :
 

 

    <input type='file' name="imgInp" id="imgInp" accept=".jpg, .png, .jpeg|images/*"/>
    <img style="max-height: 400px; max-width: 400px;" id="blah" src="#" alt="your image" />
                                        

In submitted php file:

    if($_FILES["imgInp"]["name"]!='')
    {
    $first_file=rand().$_FILES["imgInp"]["name"];
    $path="images/template/usersupload/";
    $tot_dir=$path.$first_file;
        if(file_exists($path))
        {
            move_uploaded_file($_FILES["imgInp"]["tmp_name"],$tot_dir);
        }
    }
    else
    {
        echo '<script>alert("You forgot to upload a file!!!");
    											 </script>';
    											  echo'<script type="text/javascript">';
    											 ?>
                   window.location="index.php";
              <?php
              echo '</script>';
              
    }

Please for your help.