Bom galera como diz o titulo estou tendo problemas ao utilizar a função unlink() se alguem puder me ajudar,
e parte do codigo esta abaixo e do robson v. leite o curso, mas nao sei pq tem coisas que ta dando erro aqui... bom vai ter uns aquivos que são externos, mas isso esta certinho o erro esta abaixo !
O ERRO ESTA NA PARTE ABAIXO !
Esse erro so acontece quando acionado o botão de Excluir que seria para eliminar do banco de dados e da pasta armazenada imagem... Seria alguma configuração do php.ini ou é codigo errado mesmo ? quem puder ajudar grato Plisss!
segue uma imagem do erro !
e parte do codigo esta abaixo e do robson v. leite o curso, mas nao sei pq tem coisas que ta dando erro aqui... bom vai ter uns aquivos que são externos, mas isso esta certinho o erro esta abaixo !
Código PHP:
<?php include_once"sistema/restrito_admin.php";?>
<?php include_once"sistema/validar_user.php"; ?>
<?php include_once"header.php"; ?>
<div id="local">
<div class="caminho">Onde Estou » Painel de Controle » Cadastrar Anuncio</div><!--FECHA CAMINHO-->
<div class="welcome">Olá <?php echo $clienteNome; ?> | Hoje <?php echo date('d/m/Y H:m').'h';?> | <a href="logoff.php">Deslogar</a></div><!--FECHA WELCOME-->
</div><!--FECHA LOCAL-->
<div id="content">
<?php include_once('menu.php'); ?>
<?php include_once("sistema/carregando.php");?>
<div id="content_conteudo">
<span style="font:16px 'Trebuchet MS', Arial, Helvetica, sans-serif; color:#069;">1: Informações | 2: Endereços | <strong>3: Imagens</strong></span>
<?php if(isset($_POST['executar']) && $_POST['executar'] == 'Próximo Passo'){
$imovelId = $_POST['imovelId'];
$imovelRua = strip_tags(trim($_POST['rua']));
$imovelNumero = strip_tags(trim($_POST['numero']));
$imovelBairro = strip_tags(trim($_POST['bairro']));
$imovelProximo = strip_tags(trim($_POST['proximo']));
$sql_enderecoImovel = 'UPDATE gue_imoveis SET imovelRua = :imovelRua, imovelNumero = :imovelNumero,
imovelBairro = :imovelBairro, imovelProximo = :imovelProximo WHERE imovelId = :imovelId';
try{
$query_enderecoImovel = $conecta->prepare($sql_enderecoImovel);
$query_enderecoImovel->bindValue(':imovelRua',$imovelRua,PDO::PARAM_STR);
$query_enderecoImovel->bindValue(':imovelNumero',$imovelNumero,PDO::PARAM_STR);
$query_enderecoImovel->bindValue(':imovelBairro',$imovelBairro,PDO::PARAM_STR);
$query_enderecoImovel->bindValue(':imovelProximo',$imovelProximo,PDO::PARAM_STR);
$query_enderecoImovel->bindValue(':imovelId',$imovelId,PDO::PARAM_STR);
$query_enderecoImovel->execute();
echo'Ok';
}catch(PDOexception $error_updateImovel){
echo 'Erro ao atualizar imovel'.$error_updateImovel->getMessage();
}
}?>
<?php if(isset($_POST['executar']) && $_POST['executar'] == 'Enviar Imagem'){
$imovelThumb = $_FILES['img'];
if ($imovelThumb['type'] == "image/jpg" || $imovelThumb['type']== "image/jpeg" || $imovelThumb['type']== "image/pjpeg" )
{
if ($imovelThumb['size']>1000000)
{
exit('Arquivo muito grande. Tamanho máximo permitido 1Mb. O arquivo enviado contém '.round($imovelThumb['size']/1024).'kb');
}
$imagemNome ='cliente='.$clienteId.'-'. md5(uniqid(rand().$imovelThumb['name'])).'.jpg';
$imovelPasta = "../midias/";
if (!file_exists($imovelPasta))
{
mkdir($imovelPasta);
}
include("sistema/upload.php");
$imagemCaminho = $imovelPasta.$imagemNome;
move_uploaded_file($imovelThumb['tmp_name'],$imagemCaminho);
Redimensionar($imagemCaminho, $imagemNome, 500, $imovelPasta);
$sql_cadastraImagem = 'INSERT INTO gue_midias (imovelId, imovelImg) ';
$sql_cadastraImagem .= 'VALUES (:imovelId, :nome)';
try{
$query_cadastraImagem = $conecta->prepare($sql_cadastraImagem);
$query_cadastraImagem->bindValue(':imovelId',$imovelId,PDO::PARAM_STR);
$query_cadastraImagem->bindValue(':nome',$imagemNome,PDO::PARAM_STR);
$query_cadastraImagem->execute();
echo '<div class="ok">Imagem cadastrada, envie outra!</div>';
}catch(PDOexception $erroImagem){
echo '<div class="no">Erro ao cadastrar imagem</div>';
}
}else{
echo'<div class="no">Erro ao cadastrar imagem, Envie uma Imagem no formato .JPG</div>';
}
}?>
<form name="cadastraImovelCliente" action="" method="post" enctype="multipart/form-data">
<h2>Endereço</h2>
<h2>Você pode enviar até 8 imagens!</h2>
<h3>» clique em selecionar arquivo!</h3>
<h3>» selecione a imagen</h3>
<h3>» clique em enviar imagem</h3><br />
<h2>Ao selecionar Todas as imagens clique em Finalizar!</h2>
<label>
<span>Imagens</span>
<input type="file" name="img" size="60" />
</label>
<input type="hidden" name="imovelId" value="<?php echo $imovelId; ?>"/>
<input type="submit" name="executar" id="executar" value="Enviar Imagem" />
<input type="submit" name="executar" id="executar" value="Finalizar" />
</form>
Código PHP:
<?php if(isset($_POST['executar']) && $_POST['executar'] == 'Excluir'){
$fotoId = $_POST['fotoId'];
$imovelImg = $_POST['imovelImg'];
$sql_deletaImg = 'DELETE FROM gue_midias WHERE fotoId = :fotoId';
try{
$query_deletaImg = $conecta->prepare($sql_deletaImg);
$query_deletaImg->bindValue(':fotoId',$fotoId,PDO::PARAM_STR);
$query_deletaImg->execute();
$pastaDel = '../midias';
unlink($pastaDel.'/'.$imovelImg);
echo '<div class="ok">Excluida</div>';
}catch(PDOexception $error_delImg){
echo 'Erro ao excluir';
}
}
?>
Código PHP:
<div class="galeria_all">
<?php
$sql_pegaImagem = 'SELECT * FROM gue_midias WHERE imovelId = :imovelId';
try{
$query_pegaImagem = $conecta->prepare($sql_pegaImagem);
$query_pegaImagem->bindValue(':imovelId',$imovelId,PDO::PARAM_STR);
$query_pegaImagem->execute();
$resultado_pegaImagem = $query_pegaImagem->fetchAll(PDO::FETCH_ASSOC);
}catch(PDOexception $error_pegaImagem){
echo 'Erro ao selecionar imagens';
}
foreach($resultado_pegaImagem as $resImagem){
$fotoId = $resImagem['fotoId'];
$imovelImg = $resImagem['imovelImg'];
?>
<div class="galeria_cadastro">
<span class="imagem"><img src="../midias/<?php echo $imovelImg; ?>" width="100" alt="Exibição" /></span>
<form name="execluirImagem" action="" enctype="multipart/form-data" method="post">
<input type="hidden" name="imovelId" value="<?php echo $imovelId;?>" />
<input type="hidden" name="fotoId" value="<?php echo $imovelImg;?>" />
<input type="hidden" name="fotoId" value="<?php echo $fotoId;?>" />
<input type="submit" name="executar" id="executar" value="Excluir" />
</form>
</div><!--galeria cadastro-->
<?php
}
?>
</div><!--FECHA GALERIA ALL-->
</div><!--FECHA CONTENT_CONTEUDO-->
</div><!--FECHA CONTENT-->
<?php include_once('footer.php'); ?>
segue uma imagem do erro !
Comment