Hello, I was developing the pages and suddenly the following Warning
occurred:
Warning: unlink(upload/publicacoes/Empresa Demonstração LTDA/Utilitários/Informações/2017/149029774958d4239521de6883c7046854e04138c55680ffde90a61.pdf): No such file or directory in C:\wamp64\www\MettaCont\html\deletePublicationA.php on line 30
In the system I develop is created a system of folders where the information is stored, but suddenly this error appears when I delete the publication, sometimes not all, and I do not find the error, and his file is there, as in the image: MyCodeDeletingPublications:
<?phprequire"conexao.php";
$pdo = conectar();
$codigo=$_GET['cod_publicacao'];
try{
$buscaSQL = $pdo->prepare("SELECT * FROM tbl_publicacao WHERE cod_publicacao = ?");
$buscaSQL->bindValue(1, $codigo, PDO::PARAM_INT);
$buscaSQL->execute();
$row = $buscaSQL->fetch(PDO::FETCH_ASSOC);
$publicacao = $row['publicacao'];
$ano = $row['ano'];
$tipo_publicacao = $row['fk_tipo'];
$fk_empresa = $row['fk_empresa'];
$arq=$row['arquivo'];
$searchSQL = $pdo->prepare("SELECT tbl_tipo_publicacao.cod_tipo_public, tbl_tipo_publicacao.tipo_publicacao, tbl_empresa.cod_empresa, tbl_empresa.razao_social FROM tbl_tipo_publicacao, tbl_empresa WHERE cod_tipo_public = ? AND cod_empresa = ?");
$searchSQL->bindValue(1, $tipo_publicacao, PDO::PARAM_INT);
$searchSQL->bindValue(2, $fk_empresa, PDO::PARAM_INT);
$searchSQL->execute();
$line = $searchSQL->fetch(PDO::FETCH_ASSOC);
$tipo_public = $line['tipo_publicacao'];
$razao_social = $line['razao_social'];
echo $arq;
$pasta = "upload/publicacoes/{$razao_social}/{$tipo_public}/{$publicacao}/{$ano}/";
unlink ($pasta.$arq);
$deleteSQL=$pdo->prepare("DELETE FROM tbl_publicacao WHERE cod_publicacao=:codigo");
$deleteSQL->bindValue(':codigo', $codigo);
//$deleteSQL->execute();
if($deleteSQL):
echo"<script>alert('Deletado com Sucesso!')</script>";
//echo "<script>window.history.back()</script>";
else:
echo"<script>alert('Falha ao deletar publicação!')</script>";
echo "<script>window.history.back()</script>";
endif;
}catch(PDOException $e){
echo "ERROR: " .$e->getMessage()."<br>";
echo "ERROR: " .$e->getCode();
}
?>
I'm using default utf8mb4
in the database, if this is important