Ver Mensaje Individual
  #14 (permalink)  
Antiguo 18/04/2007, 08:51
Avatar de gerson
gerson
 
Fecha de Ingreso: febrero-2005
Ubicación: Lima
Mensajes: 481
Antigüedad: 19 años, 2 meses
Puntos: 4
Re: checkbox y ficheros de directorio

hola estibaliz2006 agrege lo que necesitabas haber si te funciona
Código PHP:
if (isset($_GET['dir'])){
$path $_GET['dir'];
}else{
$path "dir";
}
if(isset(
$_POST['archivo'])){
    for(
$i=0;$i<sizeof($_POST['archivo']);$i++){
        if (
is_file($path '/' $_POST['archivo'][$i])){
            
unlink($path '/' $_POST['archivo'][$i]);
        }else{
            
rmdir($path '/' $_POST['archivo'][$i]);
        }
    }
    
header('Location: test2.php?dir='.$path);
}
echo 
'<form name="frm" method="post" action="test2.php?dir='.$path.'">';
echo 
'<table cellspacing="0" cellspadding="0" border="1">';
echo 
'<tr>';
echo 
'<td colspan="2">para los marcados<input type="submit" value="Eliminar"></td>';
echo 
'</tr>';
echo 
'<tr>';
echo 
'<td>&nbsp;</td><td>Archivo</td>';
echo 
'</tr>';
if (
$handle opendir($path))  
    { 
    while (
false !== ($file readdir($handle))) { 
        if (
$file != "." && $file != "..") {     
            
$fName $file
            
$file $path.'/'.$file
            if(
is_file($file)){////si es un fichero  
                
echo '<tr>';
                echo 
'<td><input type="checkbox" name="archivo[]" value="'.$fName.'"></td>';
                echo 
"<td><a href='".$file."'>".$fName."</a></td>";
                echo 
'</tr>';
            }else{
                if(
$handle2 opendir($file)){
                    
$contador 0;
                    while (
false !== ($file2 readdir($handle2))){
                        
$contador++;
                    }
                }
                if (
$contador == 2){
                    
$check '<input type="checkbox" name="archivo[]" value="'.$fName.'">';
                }else{
                    
$check '&nbsp;';
                }
                echo 
'<tr>';
                echo 
'<td>'.$check.'</td>';
                echo 
"<td><a href='test2.php?dir=".$file."'>".$fName."</a></td>";
                echo 
'</tr>';
            }
        }
    }
}
echo 
'</table>';
echo 
'</form>'
Saludos.
__________________