我正在尝试同时删除 mySQL 表和文件夹中的文件。到目前为止,我只能删除mysql表中的文件,但文件夹中仍然存在相同的文件。
这是我使用的删除脚本。
<?php
include "../php/conn.php";
$query = " DELETE FROM fail WHERE id_f = ? ";
if($statement = $conn->prepare($query)){
$statement->bind_param("i", $_GET['id_f']);
if($statement->execute()){
$statement->close();
echo '<script>window.alert("Fail berjaya dihapuskan.");
window.location=("../pensyarah/files.php");</script>';
}
else {
echo '<script>window.alert("Gagal menghapus fail. Sila cuba lagi.");
window.location=("../pensyarah/files.php");</script>';
}
}
else {
echo '<script>window.alert("Gagal menghapus fail. Sila cuba lagi.");
window.location=("../pensyarah/files.php");</script>';
}
?>
我正在尝试实现 PHP unlink ,但我不知道如何以及在哪里在上面的脚本中取消链接。请帮我。谢谢。
最佳答案
也许你可以尝试这样......
$source = your_local_path_to_the_file; //c:\test\123.xls
unlink($source); //try to delete it first
if (file_exists($source) {
//raise error message, failed deleting
}else{
//do your code in here to delete from mysql
}
关于php - 删除文件夹和mysql表中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47066436/