1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

删除无限级目录与文件代码共享

本帖由 wm_chief2005-09-20 发布。版面名称:后端开发

  1. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    PHP:
    <?
    //删除目录
    //本程序由wm_chief原创,如要转载,请注明作者与来源([url]http://www.phome.net[/url])
    class    del_path
    {
    function    
    wm_chief_delpath($del_path)
    {
    if(!
    file_exists($del_path))//目标目录不存在则建立
    {echo"Directory  not  found.";return    false;}
    $hand=@opendir($del_path);
    $i=0;
    while(
    $file=@readdir($hand))
    {
    $i++;
    if  (
    $file!="."&&$file!="..")
    {
          
    //目录
    if(is_dir($del_path."/".$file))
    {
    $del_s_path=$del_path."/".$file;
    $this->wm_chief_delpath($del_s_path);
    }
    else
    {
    $del_file=$del_path."/".$file;
    $this->wm_chief_file($del_file);
    }
    }
    }
    @
    closedir($hand);
    $this->wm_chief_path($del_path);
    return    
    true;
    }
    //删除文件
    function    wm_chief_file($del_file)
    {
    @
    unlink($del_file);
    }
    //删除目录
    function    wm_chief_path($del_path)
    {
    @
    rmdir($del_path);
    }
    }
    //本程序由wm_chief原创,如要转载,请注明作者与来源([url]http://www.phome.net[/url])
    ?>
     
    已获得 laogui 的点赞。
  2. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    果然高人出手就是不凡哦.....
     
  3. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    很有用,顺便问一句 有没有ASP版的
     
  4. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    不用asp......
     
  5. Tameway

    Tameway New Member

    注册:
    2005-09-06
    帖子:
    1,286
    赞:
    8
    这网站都是PHP的鸟人,我这个ASP的斑竹郁闷死了
     
  6. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    :D 语言都是通用的
     
  7. Tameway

    Tameway New Member

    注册:
    2005-09-06
    帖子:
    1,286
    赞:
    8
    通用是通用,看着不习惯
     
  8. yeshou

    yeshou New Member

    注册:
    2005-09-06
    帖子:
    7,067
    赞:
    34
    谁说的 我就听不懂法语

     
  9. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    你是野兽....你的教程呢??
    快出来..
     
  10. Tameway

    Tameway New Member

    注册:
    2005-09-06
    帖子:
    1,286
    赞:
    8
    我会法语,
     
  11. sluke

    sluke New Member

    注册:
    2005-09-04
    帖子:
    4,550
    赞:
    13
    我就会中文~~~~~~~~
     
  12. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    你是野兽:D
     
  13. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    楼上的全木JJ
     
  14. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    :D 其中一个是你
     
  15. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    楼上和楼下全木JJ
    :D
     
  16. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    楼上木jj
     
  17. turbot

    turbot New Member

    注册:
    2005-09-06
    帖子:
    3
    赞:
    0
    怎么用啊
     
  18. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    代码:
    $DelPath="DelPath";//要删除的目录
    $wm_chief=new  del_path();
    $wm_chief_ok=$wm_chief->wm_chief_delpath($DelPath);
    if($wm_chief_ok)
    {
    echo"删除完毕";
    }
     
  19. delta

    delta New Member

    注册:
    2005-09-09
    帖子:
    123
    赞:
    1
    这东西还是要慎用慎用
     
  20. 傻猪漂流记

    傻猪漂流记 New Member

    注册:
    2005-09-25
    帖子:
    19
    赞:
    0