How can I delete all the files in a folder using php/javascript. For example, this is what I am trying to do in php: using unlink function
Asked
Active
Viewed 1,207 times
-3
-
What files, on the client or on the server? – Qantas 94 Heavy Nov 21 '14 at 08:54
2 Answers
3
use
array_map('unlink', glob("some/dir/*.txt"));
this will delete all txt files in the directory for example

Att3t
- 466
- 2
- 8
1
This will give you all the files including hidden files
$files = glob('some/directory/{,.}*', GLOB_BRACE);
foreach($files as $file){
if(is_file($file))
unlink($file);
}

Bhavya Shaktawat
- 2,504
- 1
- 13
- 11