1
Hello, I was developing the pages and suddenly the following occurred Warning
:
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 folder system where is stored the information, but suddenly this error appears when I go to delete the publication, sometimes not all, and I do not find the error, being that its file is there, as in the image: My Code that deletes posts:
<?php
require "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 pattern utf8mb4
in the bank, if this is important
I may be totally wrong, but some operating systems combined with problematic PHP can give problems when using paths/files using accented characters (non-ASCII).
– Inkeliz
Read this post http://answall.com/questions/60316/pontos-e-acentos-em-urls-com-mod-rewrite
– user60252
@Saul, I’m not sure, but I believe you’ll have to escape in the directory name due to the use of spaces
– jlHertel
I was able to solve using utf8_decode
– UzumakiArtanis