function removeDemoFiles($path) { global $target; $path .= end(str_split($path)) !== '/' ? '/' : ''; foreach (glob($path . "*") as $file) { if (is_dir($file)) { removeDemoFiles($file); } if (is_file($file)) { unlink($file); } } $dirf = $target . '/files/'; // Remove Directory once Files have been removed (If Exists) if (is_dir($path) && $path !== $dirf) { rmdir($path); } }
function removeDemoFiles($path) { $path .= end(str_split($path)) !== '/' ? '/' : ''; foreach (glob($path . "*") as $file) { if (is_dir($file)) { removeDemoFiles($file); } if (is_file($file)) { unlink($file); } } // Remove Directory once Files have been removed (If Exists) if (is_dir($path) && $path !== DIR_FILES_UPLOADED . '/') { rmdir($path); } }