westman Posted April 22, 2018 Share Posted April 22, 2018 Hi all, I am working with some old script to remove files and folders. $directory = "../pics/$id"; function delete_directory($directory, $empty=false) { if(substr($directory,-1) == DIRECTORY_SEPARATOR){ $directory = substr($directory,0,-1); } if(!is_dir($directory) || !is_readable($directory)){ return false; } else{ $handle = opendir($directory); while (false !== ($item = readdir($handle))){ if($item != '.' && $item != '..'){ $path = $directory.DIRECTORY_SEPARATOR.$item; if(is_dir($path)){ delete_directory($path); } else{ unlink($path); } } } closedir($handle); if($empty == false){ if(!rmdir($directory)){ return false; } } return true; } } delete_directory($directory); Will this still work in the new php version? Link to comment Share on other sites More sharing options...
niche Posted April 23, 2018 Share Posted April 23, 2018 Can you test it in a new version? It's the best way to find out. Link to comment Share on other sites More sharing options...
westman Posted April 28, 2018 Author Share Posted April 28, 2018 It works fine. I just tested it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now