I want to make a delay in my PHP codes to alert my Javascript code and then run header function in the bottom.
I tried to implement my ideas with sleep function in php . But when i tried it , all of the program sleeps for seconds .
<?php
echo "<pre>";
print_r($_FILES);
echo "</pre>" ;
$randNum = rand(0,999);
$fileAd = "Images\User".$randNum ;
$mkFile = mkdir($fileAd);
$fileDir = __DIR__ ;
$uploadFile = $fileDir. "\\" . $fileAd . "\\" . $_FILES['userfile']['name'];
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadFile)){
echo "<script>
alert(\"Thanks\");
</script>";
}
$contentFile = $fileDir . "\\" . $fileAd . "\\" . "User" . $randNum . ".txt" ;
$str = "" ;
foreach($_POST as $key=>$value){
if(is_array($value)){
$str .= "$key : ";
$str .= implode(" , ",$value).PHP_EOL;
}else {
$str .= "$key : $value".PHP_EOL;
}
}
file_put_contents($contentFile,$str);
header("Location: sugFuncs.php");
?>