+ Reply to Thread
Results 1 to 8 of 8

Thread: How to whole remove dir in php

  1. #1
    phpasks is offline x10 Sophmore phpasks is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    145

    How to whole remove dir in php

    I have below proble problem when remove whole dir.



    it keeps giving me this PHP error :
    Warning: rmdir(../../infusions/theme_database/temp/f8e0c65c0461b6631aa83234f20c9011//themes/DarkZik/forum) [function.rmdir]: Directory not empty in /home/themes/public_html/infusions/theme_database/theme_submission_inc.php on line 15

    Cheer
    Asif Khalyani
    Asif Khalyani
    http://www.phpasks.com

  2. #2
    scorch94 is offline x10 Sophmore scorch94 is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    228

    Re: How to whole remove dir in php

    Clearly, you've got to run a loop to delete all the files in directory previously

  3. #3
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: How to whole remove dir in php

    here is something small and fast you can use.

    PHP Code:
    function delete_directory($dirname) {
      if (
    is_dir($dirname)){
        
    $dir_handle opendir($dirname);
      }
      if (!
    $dir_handle){
        return 
    false;
      }
      while(
    $file readdir($dir_handle)) {
        if (
    $file != "." && $file != "..") {
          if (!
    is_dir($dirname."/".$file)){
            
    unlink($dirname."/".$file);
          }else{
            
    delete_directory($dirname.'/'.$file);
          }
        }
       
    closedir($dir_handle);
       
    rmdir($dirname);
      return 
    true;

    always worth a shot. Not sure if it works because I just googled that

    I would love to change the world, but they won't give me the source code

  4. #4
    scorch94 is offline x10 Sophmore scorch94 is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    228

    Re: How to whole remove dir in php

    That one should work out, as far as I see.

  5. #5
    phpasks is offline x10 Sophmore phpasks is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    145

    Re: How to whole remove dir in php

    I know this recrusive function through delete whole directory.

    Any other command to direct remove whole dir.

    Any one knows only one command through delete whole dir.

    Quote Originally Posted by Chris S View Post
    here is something small and fast you can use.

    PHP Code:
    function delete_directory($dirname) {
      if (
    is_dir($dirname)){
        
    $dir_handle opendir($dirname);
      }
      if (!
    $dir_handle){
        return 
    false;
      }
      while(
    $file readdir($dir_handle)) {
        if (
    $file != "." && $file != "..") {
          if (!
    is_dir($dirname."/".$file)){
            
    unlink($dirname."/".$file);
          }else{
            
    delete_directory($dirname.'/'.$file);
          }
        }
       
    closedir($dir_handle);
       
    rmdir($dirname);
      return 
    true;

    always worth a shot. Not sure if it works because I just googled that
    Asif Khalyani
    http://www.phpasks.com

  6. #6
    phpasks is offline x10 Sophmore phpasks is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    145

    Re: How to whole remove dir in php

    any one help me??????
    Asif Khalyani
    http://www.phpasks.com

  7. #7
    KSclans is offline x10 Sophmore KSclans is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    198

    Re: How to whole remove dir in php

    it say on line 15 do you find any problem in line 15 ? I need more info...

  8. #8
    phpasks is offline x10 Sophmore phpasks is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    145

    Re: How to whole remove dir in php

    Quote Originally Posted by KSclans View Post
    it say on line 15 do you find any problem in line 15 ? I need more info...

    Which 15 line man
    You can call you
    Asif Khalyani
    http://www.phpasks.com

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  3. Pregunta sobre las Configuraciones PHP
    By Trevelin in forum Soporte
    Replies: 11
    Last Post: 04-28-2008, 01:50 PM
  4. Important PHP Information
    By Bryon in forum News and Announcements
    Replies: 0
    Last Post: 11-21-2007, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers