Delete all the files inside folder:PHP

Did you ever come across a situation where you want to delete all the file with a particular extension from the folder?

The following code should be used To delete all the files present inside the folder:
//Here I want to delete all the word documents inside download folder.

<?php
$mypath=”public_html/download”; //replace it with your file path.
$unlink_files = glob($mypath.’*.doc’); // get all file names
foreach($unlink_files as $file){ // iterate files
if(is_file($file))
unlink($file); // delete file
}

?>

 

I use this script to delete error_log file.

I know its not a right thing to delete the error_log file but sometimes it is needed 😉

27 thoughts on “Delete all the files inside folder:PHP

  1. Pingback: vape eliquid
  2. Pingback: czyszczenie strony
  3. Pingback: Games tablet
  4. Pingback: toy store 4
  5. Pingback: best scripts
  6. Pingback: comprar biquinis
  7. Pingback: Cheap domains
  8. Pingback: Pelco
  9. Pingback: bath salt scoop
  10. Pingback: Kalkulation
  11. Pingback: kona coffee store
  12. Pingback: kona coffee brands
  13. Pingback: pure kona coffee
  14. Pingback: kona coffee
  15. Pingback: kona coffee beans
  16. Pingback: 100% kona coffee
  17. Pingback: 100% kona coffee
  18. Pingback: Lo mejor de Chile

Leave a Reply