PHP Empty a Folder
by webmasterjunkie on Oct.30, 2010, under Designs, Internet, PHP, Programming, Service, Web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function empty_directory_folder ($dir, $deleteMe) { if (!$dh = @opendir ($dir)) return; while (false !== ($obj = readdir($dh))) { if($obj == '.' || $obj == '..') continue; if (!@unlink ($dir . '/' . $obj)) empty_directory_folder ($dir . '/' . $obj, true); } closedir ($dh); if ($deleteMe){ @rmdir ($dir); } } // Call the function like this // You can change the second argument to true if you want to delete the folder too empty_directory_folder ('../tmp', false); |
Link to this post!

Connect
Enter your WordPress.com blog URL
http://.wordpress.com
Proceed