PHP – Delete all files in a directory

Martin Zellerphp 1 Comment

Simple question – simple answer:

How do I delete all files in a directory with PHP?
[php]$files = glob(‘/path/to/directory/*.*’);
foreach($files as $file)
unlink($file);[/php]

Comments 1

  1. Pingback: PHP – Delete files by pattern | Freelancer Martin Zeller - php asp.net java c# .net c++ xhtml seo magento zend framework coremedia dotnetnuke telerik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.