Go Back   Internet Business Forums > Design & Development

Reply
 
Thread Tools Display Modes
Old 29-11-2006, 07:53 PM   #1 (permalink)
co-admin
 
army's Avatar
 
Join Date: Oct 2006
Location: Belgium
Posts: 666
Default [ SCRIPT ] Delete folders (directories)

The script below deletes a folder, even if there are still files inside. Of course, it is only able if the CHMOD is right .

PHP Code:
<?php
function remove_dir($dir) {
  
$handle opendir($dir);
  while (
false!==($item readdir($handle))) {  
    if(
$item != '.' && $item != '..') {
      if(
is_dir($dir.'/'.$item)) {
               
remove_dir($dir.'/'.$item);
           } else {
        
unlink($dir.'/'.$item);
           }
       }
  }
  
closedir($handle);
  if(
rmdir($dir)) {
       
$success true;
  }
  return 
$success;
}
?>
army is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT +1. The time now is 11:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.