Delete Files in Folders with PHP

The script below is useful when you want to delete files in a specified folder in any path.

<?php

$files = glob('D:/archive_scanned_dox/*');     // get all file names in your drive D:/archive_scanned_dox
foreach($files as $file){    // iterate files
  if(is_file($file))
    unlink($file);    // delete file
}

echo "<script> window.close();</script>"; // Include this if you want to close the browser tab after delete

?>

Pretty easy aren't yah! 

Labels: ,