PHP delete files from specific folders or directory
If you want to remove or delete files from a specific folder or directory then following code snippet will help you to remove files. This code work recursively and delete all files inside that directory.
delete files from specific folders or directory
<?php $direpath='/path/to/your/directory/'; function EmptyDir($dir) { $handle=opendir($dir); while (($file = readdir($handle))!==false) { echo "$file <br>"; @unlink($dir.'/'.$file); } closedir($handle); } EmptyDir($direpath); ?>