..:: MX Studio Fóruns ::..: Listar e Excluir - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Listar e Excluir

#1 User is offline   leo.tecnico.micros 

  • Group: Membros
  • Posts: 2
  • Joined: 13-May 11

Posted 13 May 2011 - 11:55 AM

Estou tentando colocar para excluir arquivo mais não estou conseguindo o q ei estou errando?

Página Listar

<script>

function excluir(){
if(confirm("Deseja excluir este aviso")){
location.href='excluir.php'
}
}

</script>

<?php

if(isset($_POST['acao']) && $_POST['acao'] == 'cadastrar'){
$img = $_FILES['img'];
$ano = $_POST['ano'];
if($ano == '2004'){$pasta = '1sec/adtpess/2004/';}
if($ano == '2005'){$pasta = '1sec/adtpess/2005/';}
if($ano == '2006'){$pasta = '1sec/adtpess/2006/';}
if($ano == '2007'){$pasta = '1sec/adtpess/2007/';}
if($ano == '2008'){$pasta = '1sec/adtpess/2008/';}
if($ano == '2009'){$pasta = '1sec/adtpess/2009/';}
if($ano == '2010'){$pasta = '1sec/adtpess/2010/';}
if($ano == '2011'){$pasta = '1sec/adtpess/2011/';}

$contar = count($img['name']);
$ok = 0;
$erro = 0;
for($i = 0; $i < $contar; $i++){
$nome = $img['name'][$i];
$tmp = $img['tmp_name'][$i];
if(!empty($nome)){
if(move_uploaded_file($tmp, $pasta.$nome)){
$ok++;
}else{
$erro++;
}
}
}
}



?>

<script type="text/javascript">
function AddCampo(id){
el = document.getElementById(id);
el.innerHTML += '<label><span></span></label><input type="file" name="img[]" /><br /><br/>';
}


</script>

<div id="hr">
<div class="hr1" style="margin-right:4px">Aditamento de Pessoal</div>
</div>
<br/>

<?php

if($_SESSION["loged"] == "ok" && $_SESSION["sec_id"] == 6){ //trocar para ok

?>

<b>Cadastro de Aditamento de Pessoal</b>
<br/><br/>
<form action="" method="post" enctype="multipart/form-data">
Arquivo:<br/>
<input type="file" name="img[]" id="img"/>&nbsp;&nbsp;<a href="#" onclick="AddCampo('img-extra')">Add Campo</a>
<br/><br/>
<div id="img-extra"></div>
<br/><br/>
Selecione o Ano:<br/>
<select name="ano">
<option></option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
</select>
<br/><br/>
<input type="submit" class="btn" value="Enviar" />
<input type="hidden" name="acao" value="cadastrar" />
</form>
<br/>
<hr></hr>
<h2>Aditamento de Pessoal</h2>
<?php
if(isset($ok) && isset($erro)){

echo '<br/>Arquivos enviados com sucesso :'.$ok;
echo '<br />';
echo 'Arquivos não enviados :'.$erro;
}

include("class.File.php3");
$ano = $_GET["ano"];
if($ano == ""){
$ano = date("2011");
}

$aFileClass = new File();
$aDirContents = $aFileClass->get_files("1sec/adtpess/". $ano ."/");
@rsort($aDirContents);
for($nIndex = 0; $nIndex < count($aDirContents); $nIndex++){

if($nIndex == 0){
include("1sec/adtpess/menu.php");
}

$aCurFile = $aDirContents[$nIndex];

$fs = strlen($aCurFile);
$ret = "";
if($fs >= 65){
$ret = "...";
}

if($aCurFile != "class.File.php3"){
$filename = substr($aCurFile, 0, 65);
echo "<table border='1' width='100%'><tr><td width='90%'><a href='1sec/adtpess/". $ano ."/". $aCurFile ."' target='blank' style='text-transform:lowercase;margin-left:10px'>". $filename . $ret ."</a><br/></td><td width='10%'><a href='#' onClick='excluir()';?>
Excluir
</a></td></tr></table>";
}
}

?>

<?php

}else{

include("class.File.php3");
$ano = $_GET["ano"];
if($ano == ""){
$ano = date("2011");
}

$aFileClass = new File();
$aDirContents = $aFileClass->get_files("1sec/adtpess/". $ano ."/");
@rsort($aDirContents);
for($nIndex = 0; $nIndex < count($aDirContents); $nIndex++){
if($nIndex == 0){
include("1sec/adtpess/menu.php");
}

$aCurFile = $aDirContents[$nIndex];

$fs = strlen($aCurFile);
$ret = "";
if($fs >= 65){
$ret = "...";
}

if($aCurFile != "class.File.php3"){
$filename = substr($aCurFile, 0, 65);
echo "<a href='1sec/adtpess/". $ano ."/". $aCurFile ."' target='blank' style='text-transform:lowercase;margin-left:10px'>". $filename . $ret ."</a><br/>";
}
}
}
?>

Página Excluir

<?php

$arquivo = "<a href='1sec/adtpess/". $ano ."/". $aCurFile ."' target='blank' style='text-transform:lowercase;margin-left:10px'>".$filename.$ret ."</a>";
if (unlink($arquivo)){
echo "<script>alert('Excluido com sucesso');location='http://10.1.4.4/intranet/'</script>";
}else{
echo "<script>alert('Erro ao excluir');location='http://10.1.4.4/intranet/'</script>";
}
?>
0

#2 User is offline   leo.tecnico.micros 

  • Group: Membros
  • Posts: 2
  • Joined: 13-May 11

Posted 14 May 2011 - 03:38 PM

??
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)