嘿,我在删除mysql数据以及在同一时间删除文件夹中的图像时遇到问题。
我很想从数据库中删除mysql映像链接,但是我无法同时从ftp文件夹中删除映像。如果您能帮助我,那我做错了什么,您可以保存我的第3天^^
我最近更改了代码,似乎一切正确,但它没有从ftp中删除图像?
gallery.php
<form action="../function.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="urun_id" value="<?php echo $_GET['urun_id']; ?>">
<input type="hidden" name="urunfoto_resimyol[]" value="<?php echo $urunfotocek['urunfoto_resimyol']; ?> ">
<div align="right" class="col-md-6">
<button type="submit" name="urunfotosil" class="btn btn-danger "><i class="fa fa-trash" aria-hidden="true"></i> Delete Selected</button>
<a class="btn btn-success" href="urun-foto-yukle.php?urun_id=<?php echo $_GET['urun_id'];?>"><i class="fa fa-plus" aria-hidden="true"></i> Upload Images</a>
...
function.php
if(isset($_POST['urunfotosil'])) {
$urun_id=$_POST['urun_id'];
echo $checklist = $_POST['urunfotosec'];
foreach($checklist as $list) {
$sil=$db->prepare("DELETE from urunfoto where urunfoto_id=:urunfoto_id");
$kontrol=$sil->execute(array(
'urunfoto_id' => $list
));
}
if ($kontrol) {
$resimsilunlink=$_POST['urunfoto_resimyol'];
foreach ($resimsilunlink as $resimyol) {
unlink("../../$resimyol");
}
Header("Location:../production/urun-galeri.php?urun_id=$urun_id&durum=ok");
} else {
Header("Location:../production/urun-galeri.php?urun_id=$urun_id&durum=no");
}
}