Reputation: 26
The file I'm working on is 1 directory above.
The image is in this path
But I got this error
This is the code I have:
$ver=mysqli_query($db, "SELECT * from slides where id = '".$_POST['id']."'");
$mostra=mysqli_fetch_assoc($ver);
unlink("../img/slide/'".$mos['img']."'");
If I use the normal name instead of the one I go get in the database, It deletes it.
SOLVED
unlink("../img/slide/".$mos['img']);
Just needed to remove the '' in the unlink.
Upvotes: 0
Views: 24
Reputation: 11375
You have a rogue '
in your unlink()
. You can see it's trying to remove '1.jpg'
which doesn't exist (I'm assuming the file name is 1.jpg
- without the '
.)
Change your unlink()
to remove the '
around the variable.
unlink("../img/slide/".$mos['img']);
Upvotes: 2