0
I am trying to use unlink to delete from a directory several images do not know what is happening apparently the logic is correct, my method is as follows:
public function deleteImagem($id) {
$selectDasImagens = PDOUtil::getStance()->prepare("select nome FROM imagem where id_pagina=:id");
$selectDasImagens->bindValue(":id", $id);
$selectDasImagens->execute();
while ($linha = $selectDasImagens->fetch(PDO::FETCH_OBJ)) {
echo unlink("../uploaded/$linha->nome");
}
}
someone has been there.
you want to delete multiple files?
$linha->nome
comes with the extension?– rray
yes already comes with the name and yes I want to delete several files, the interesting thing is that when I do without while it erases a file quietly.
– André Martins
echo writes zero(false)?
– rray
that’s right, correct answer.
– André Martins
You may not be allowed to delete the file, or name is not correct, try with:
echo unlink("../uploaded/{$linha->nome}");
. You can also delete passand the full file path.– rray