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 😉

130 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
  41. Pingback: dumpling Boston
  42. Pingback: hotmart
  43. Pingback: bad credit loans
  44. Pingback: NBA
  45. Pingback: investment capital
  46. Pingback: Houston, TX
  47. Pingback: kona bean coffee
  48. Pingback: pure kona
  49. Pingback: gender equality
  50. Pingback: Concrete
  51. Pingback: opera
  52. Pingback: dog sunglasses
  53. Pingback: #bruhtawk
  54. Pingback: rockhounding
  55. Pingback: WEB SOLUTIONS
  56. Pingback: fitness legíny
  57. Pingback: Handmade jewelry
  58. Pingback: build a robot
  59. Pingback: general contractor
  60. Pingback: movers
  61. Pingback: טופ פארם
  62. Pingback: epoxy repairs
  63. Pingback: Server
  64. Pingback: iphone repair
  65. Pingback: vip women
  66. Pingback: Google
  67. Pingback: best dildo
  68. Pingback: 먹튀검증업체
  69. Pingback: 메이저놀이터
  70. Pingback: 먹튀사이트
  71. Pingback: pizza coupon codes
  72. Pingback: VIAGRA
  73. Pingback: Licence
  74. Pingback: anime
  75. Pingback: Project 2019
  76. Pingback: regulation
  77. Pingback: 안전놀이터
  78. Pingback: 메이저토토
  79. Pingback: cbd capsules
  80. Pingback: bunny ear vibrator
  81. Pingback: xxx
  82. Pingback: buy biiig stiiizy
  83. Pingback: Sauna
  84. Pingback: BLK-429

Leave a Reply