I tried to add a delete images function in my website, but when I try, I was prompt a blank page as it doesn't echo anything and it doesn't remove any file from my folder..
Image.php
<form action="deleteImage.php" method="post">
<input name="delete_file" type="hidden" value="<?php echo $one_image["FILE_NAME"]?>">
<input type="submit" value="Delete">
</form>
deleteImage.php
if (array_key_exists('delete_file', $_POST)) {
$path = "images";
$filename = $_POST['delete_file'];
if (file_exists($filename)) {
unlink($path . "/" . $filename);
echo 'File ' . $filename . ' has been deleted';
} else {
echo 'Could not delete ' . $filename . ', file does not exist';
}
}
if (file_exists($filename)), but trying to delete usingunlink($path . "/" . $filename);? So you either need to add the$path . "/" .to yourfile_exists()->if (file_exists($path . "/" . $filename))or remove it from theunlink()->unlink($filename);, depending on the file location