Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/09/2008, 22:37
Avatar de Ronruby
Ronruby
 
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 10 meses
Puntos: 416
Respuesta: Eliminar archivos subcarpeta

Como te dijo Okram. En los comentarios publicados hay varios metodos para borrar directorios y subdirectorios.

Código PHP:
<?php
function rm_recursive($filepath)
{
    if (
is_dir($filepath) && !is_link($filepath))
    {
        if (
$dh opendir($filepath))
        {
            while ((
$sf readdir($dh)) !== false)
            {
                if (
$sf == '.' || $sf == '..')
                {
                    continue;
                }
                if (!
rm_recursive($filepath.'/'.$sf))
                {
                    throw new 
Exception($filepath.'/'.$sf.' could not be deleted.');
                }
            }
            
closedir($dh);
        }
        return 
rmdir($filepath);
    }
    return 
unlink($filepath);
}
?>