Hi every body please help me with this problem:
I want to upload a file from a page, but first I check if the file exists before or not and if it exists I ask the user to overwrite the file or not ,but I don't Know how to get confirm message answer in php to continue the correct action

Here is my php code :
PHP Code:
<?php
if (isset($_GET['load']))
$load $_GET['load'];

if (isset(
$_POST['openerhref']))
$openerhref $_POST['openerhref'];

if (
$load == "false")
{
    
$file_name $_FILES['rulefile']['name'];
    
$temp_name $_FILES['rulefile']['tmp_name'];
    
$file_type $_FILES['rulefile']['type'];
    
$file_size $_FILES['rulefile']['size'];

    if (
is_uploaded_file($temp_name))
    {
        if (
$file_type != "application/octet-stream")
        {
            echo 
"<script>alert('Type of file is not accepted!')</script>";
        }
        else
        {
            if (
file_exists("../../core/snort/rules/$file_name"))
            {
                echo 
"<script>ans = confirm('File already exists.Do you want to overwrite it?');
                if (!ans)
                    document.location = 'addRuleFile.php?load=true';
                else
                {
                                     [COLOR="
Red"]  I DON'T KNOW WHAT TO DO HERE TO CONTINUE [/COLOR]OVERWRITING
                } 
                </script>"
;
            }
            else
            {
                
move_uploaded_file($temp_name"../../core/snort/rules/$file_name");
                
$file_size round($file_size /= 1024,1);
                
$unit " KB";

                if (
$file_size 1024)
                {
                    
$file_size round($file_size /= 1024,1);
                    
$unit " MB";
                }
                
$file_size .= $unit;
                
addRuleFile($file_name,$file_size);

                echo 
"<script>window.opener.location.href='$openerhref'; window.opener.location.reload();</script>";
                echo 
"<script>window.close();</script>";
            }
        }
    }
    else
    {
        echo 
"<script>alert('There was a problem processing the file.')</script>";
    }
}
?>
HTML Code:
<form name="save" enctype="multipart/form-data" method="POST" action="<?php $PHP_SELF ?>?load=false" onsubmit="return applySave(this);">
<table>
<tr>
<td class="label" width="100%"><input type="file" id="rulefile" size="28" name="rulefile" style="font-size:12;" >
<table></td>
</tr>
</table>

<table align="right" border="0" cellpadding="0">
<tr>
<td > <input type="submit" value="Save" class="but"></td>
<td > <input type="button" value="Close" class="but" onclick="window.close();"></td>
</tr>
</table>
</form>