php - Unlink image while deleting row - pdo -
i trying unlink()
image folder while it's corresponding deleting row database. deleting row db works great can't unlink
work.
i googled 2 hours , tried lot of thing it's still not working, think have small glitch can't figure out.
can suggest try.
<?php $pdo = connect(); if (isset($_get['delete'])) { $delete_id = $_get['delete']; $img = "select slika filmovi id = $delete_id"; $q = $pdo->prepare($img); $q->execute(); $row = $q->fetchall(); $sql = "delete filmovi id = :filmid"; $query = $pdo->prepare($sql); $query->bindparam(':filmid', $delete_id, pdo::param_int); $query->execute(); $image = $row['slika']; unlink("assets/img/movies/.'$image"); header("location: index.php?movies"); die(); }
unlink("assets/img/movies/.'$image");
so $image
contains "image.jpg". path you've constructed
assets/img/movies/.'image.jpg
what want
unlink("assets/img/movies/". $image);
Comments
Post a Comment