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.

$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
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 😉

65 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
  19. Pingback: RK OCEANS
  20. Pingback: prix windows 10
  21. Pingback: travel backpack
  22. Pingback: agencia seo mexico
  23. Pingback: importar de china
  24. Pingback: cbd vergleich
  25. Pingback: Brazilian Army
  26. Pingback: machine learning
  27. Pingback: eyeglasses
  28. Pingback: vanquish fitness
  29. Pingback: vinyl cutter
  30. Pingback: harmonic patterns
  31. Pingback: Movers
  32. Pingback: seo agency
  33. Pingback: 薬の通販
  34. Pingback: Mexico
  35. Pingback: kona bean
  36. Pingback: Fashion Week
  37. Pingback: LAFW
  38. Pingback: travel
  39. Pingback: Best business
  40. Pingback: college grants

Leave a Reply