Post Pic

How to delete all files in directory using php.

Just use the following php code to delete all the files in a directory.

$dirpath= '[dirname]';
if ($handle = @opendir($dirpath)) {
while (false !== ($file = @readdir($handle))) { if ($file != '.' and $file != '..') { echo $file . ' deleted.'; @unlink($dirpath . '/' . $file); } } @closedir($handle);
}

No related posts.

One Response

04.17.10

Hello This is a great blog keep your good work and thank you for hvar in with me So nice to hear frome you.Thanks!

Leave Your Response

* Name, Email, Comment are Required