Bruno Moutinho
Bruno Moutinho

Reputation: 26

Can't find a directory vie unlink

The file I'm working on is 1 directory above.

The image is in this path

https://i.sstatic.net/lnKjZ.png

But I got this error

https://i.sstatic.net/wsrxO.png

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

Answers (1)

ʰᵈˑ
ʰᵈˑ

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

Related Questions