特定ディレクトリ内のファイルを一括削除

ディレクトリ構成
├ /upload_files/(削除するファイルを収めるのディレクトリ)
└ /file_delete_admin/
└ index.php(スクリプト本体)
ソース ダウンロード
ソース
<?php
//ファイル削除処理
if($_REQUEST['del'] == "del"){
$CacheDir = "../upload_files/";//ディレクトリ名
$dir = opendir($CacheDir);
while(($ent = readdir()) !== FALSE) {
if ($ent != "." && $ent != "..") {
unlink($CacheDir."/".$ent);
}
}
echo '<span style="color:#993300;">ディレクトリ内のファイルを<br />全て削除しました。</span>';
}
?>
<ol>
<?php
//ファイル一覧表示
if ($dir = opendir("../upload_files")) {//ディレクトリ名
while (($file = readdir($dir)) !== false) {
if ($file != "." && $file != "..") {
echo '<li><a href="../upload_files/' . $file . '" target="_blank">' . $file . '</a><br /></li>';
}
}
closedir($dir);
}
?>
