Hey im having an issue on deleting mysql data and also deleting images on folder at the same time.
Im okey with deleting mysql image link from database but i couldnt manage to delete images from ftp folder at the same time. What im doing wrong if you can help me you can save my 3th day ^^
I have changed codes recently seems like all correct but it doesnt remove the images from 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");
}
}