<?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 ?>