metalero 0 Denunciar post Postado Fevereiro 4, 2011 Bom Dia, estou fazendo um site de imoveis não estou conseguindo deletar as fotos do anuncio, só consegui deletar o anuncio do cliente como faço para deletar as fotos junto com o anuncio e também apagar as fotos da pasta ? <div id="content"> <?php include_once("menu.php");?> <div id="content_conteudo"> <?php include_once("sistema/carregando.php");?> <table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr style="background:#666; color:#FFF;"> <td align="center">Anúncio ID:</td> <td align="center">Titulo:</td> <td align="center">Visitas:</td> </tr> <?php $imovelStatus = 'pendente'; $data = date('Y-m-d H:m:s'); $sql_pegaAtivos = 'SELECT * FROM imoveis WHERE clienteId = :clienteId AND imovelStatus = :imovelStatus '; try{ $query_pegaAtivos = $conecta->prepare($sql_pegaAtivos); $query_pegaAtivos->bindValue(':clienteId',$clienteId,PDO::PARAM_STR); $query_pegaAtivos->bindValue(':imovelStatus',$imovelStatus,PDO::PARAM_STR); $query_pegaAtivos->execute(); $resultado_pegaAtivos = $query_pegaAtivos->fetchAll(PDO::FETCH_ASSOC); }catch(PDOexception $error_pegaAtivos){ echo 'Erro ao pegar ativos!'; } foreach($resultado_pegaAtivos as $resAtivos){ $anuncioId = $resAtivos['imovelId']; $anuncioTitulo = $resAtivos['imovelTitulo']; $anuncioInicio = $resAtivos['imovelCadastro']; $anuncioFinal = $resAtivos['imovelTermino']; $anuncioVisitas = $resAtivos['imovelVisitas']; $i++; if($i % 2 == 0){ $cor = 'style="background:#E6FFF2"'; }else{ $cor = 'style="background:#f4f4f4;"'; } $dataHoje = mktime(0,0,0,date('m'),date('d'),date('Y')); $dataFim = mktime(0,0,0,date('m',strtotime($anuncioFinal)),date('d',strtotime($anuncioFinal)),date('Y',strtotime($anuncioFinal))); $executaData = $dataFim - $dataHoje; $faltamDias = floor($executaData/(60*60*24)); ?> <tr <?php echo $cor;?>> <td align="center"><?php echo $anuncioId ;?></td> <td align="center"><?php echo $anuncioTitulo;?></td> <td align="center"><?php echo $anuncioVisitas;?></td> </tr> <?php } ?> </table> <?php if(isset($_POST['executar']) && $_POST['executar'] == 'Excluir'){ $imovelId = $_POST['imovelId']; $sql_deleta = 'DELETE FROM imoveis WHERE imovelId = :imovelId'; try{ $query_deleta = $conecta->prepare($sql_deleta); $query_deleta->bindValue(':imovelId',$imovelId,PDO::PARAM_STR); $query_deleta->execute(); echo '<div class="ok">Excluida</div>'; }catch(PDOexception $error_delImg){ echo 'Erro ao excluir'; } } ?> <table align="right" width="100%" border="2" cellspacing="3" cellpadding="0"> <tr style="background:#666; color:#FFF;"> <td align="center">Excluir Anúncio:</td> <td align="right"> <form name="excluirImagem" action="" enctype="multipart/form-data" method="post"> <input type="text" name="imovelId" value="<?php echo $imovelId;?>" /> <input type="submit" name="executar" id="executar" value="Excluir" /> </form> </td> </table> </div><!--content_conteudo---> </div><!--content---> Obrigado pela atenção Compartilhar este post Link para o post Compartilhar em outros sites
William Bruno 1501 Denunciar post Postado Fevereiro 4, 2011 com a função unlink() você apaga arquivos http://php.net/unlink Compartilhar este post Link para o post Compartilhar em outros sites