Почему после удаления файла он снова появляется?
Ситуация такая. Загружаю файл в папку, файл загружен. Удаляю файл, перезагружаю страницу, файл опять появляется. Как это убрать?
<?php
$status = "";
$filename_x = "Choose File";
$allowedMIMETypes = array('jpg', 'jpeg', 'gif', 'png');
$flag = 1;
if(isset($_POST["submit"]) && !isset($_FILES['file'])) {
$check = getimagesize($_FILES['file']['name']);
if ($check !== false) {
$flag = 1;
} else {
$flag = 0;
}
}
if (file_exists(basename($_FILES['file']['name']))) {
$status = "Sorry, file already exists.";
$flag = 0;
}
if ($_FILES['file']['size'] > 500000) {
$status = "Sorry, your file is too large.";
$flag = 0;
}
if(!in_array(strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION)), $allowedMIMETypes)) {
$status = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$flag = 0;
}
if ($flag == 0) {
$status = "Sorry, your file was not uploaded.";
} else {
if (move_uploaded_file($_FILES["file"]["tmp_name"], basename($_FILES['file']['name']))) {
$status = htmlspecialchars(basename( $_FILES["file"]["name"])). " has been uploaded.";
} else {
$status = "Sorry, there was an error uploading your file.";
}
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap" rel="stylesheet">
<title></title>
</head>
<body>
<main>
<form method="post" action="" enctype="multipart/form-data">
<label for="file"><?php echo $filename_x?></label><br>
<input id="submit" type="submit" name="submit" value="Upload"><br>
<input id="file" type="file" name="file">
</form>
<p><?php echo $status?></p>
<?php
$path = scandir(getcwd());
$restrictions = array('.', '..', 'index.css', 'index.php');
foreach ($path as $f){
if(!in_array($f, $restrictions) and !is_dir($f)) echo "<a href='".$f."'>".$f."</a>"."<br>";
if(!in_array($f, $restrictions) and is_dir($f)) echo "<a href='".$f."'>".$f."/</a>"."<br>";
}
?>
</main>
</body>
</html>
<br>