-1
如何从文件夹中删除单个文件?当我点击我的删除链接时,它会从文件夹中删除所有上传的文件。如何从文件夹中删除单个文件?
链接:
<td><a href="Ad_delete.php?$Id=<?php echo $Row['Id'];?>" onClick="return confirm('Are you sure you want to delete this selected file ?')">Delete</a>
代码:
<?php
// Including the database connection file
include_once 'Ad_updbconnect.php';
// Getting Id of the data from url
$Id = $_GET['Id'];
$Del = glob('uploads/*'); // Get all file names
foreach ($Del as $File) {
if (is_file($File)) {
unlink($File); // delete file !
}
}
// Deleting the row from table
$Result = mysqli_query ($Con, "DELETE FROM ibgsec_uploads WHERE Id=$Id");
$Row = mysqli_fetch_array($Result);
// Redirecting to the display page.
header("location: Ad_uploads.php");
?>
这是留给我工作的唯一的东西,我试过很多方法来正确地执行命令,但它不起作用。