Unlink to multiple files

0

I am trying to use the unlink to delete from a directory several images I 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 already gone through this.

    
asked by anonymous 14.06.2015 / 02:24

1 answer

1

resolved as follows:

I first opened the terminal and edited the directory permissions: chmod 777 then I removed the echo from the method.

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)) {
    unlink("../uploaded/$linha->nome");
}

}

thanks @rray

    
14.06.2015 / 02:51