php delete all files in folder

Solutions on MaxInterview for php delete all files in folder by the best coders in the world

showing results for - "php delete all files in folder"
Greta
21 Feb 2018
1$files = glob('path/to/temp/*'); // get all file names
2foreach($files as $file){ // iterate files
3  if(is_file($file)) {
4    unlink($file); // delete file
5  }
6}