<?php
$path = "./user";
$dh = dir($path);
while( ($file=$dh->read()) !== false) {
if( $file=="." || $file=="..")continue;
$realfile = $path . "/" . $file;
echo (is_dir($realfile))? "<tr><td><a href='opendir.php?f=$file' title='Click to Open'>$file</a></td>":"<tr><td><a href='download.php?f=$file' title='Click to Download'>$file</a></td>";
echo "<td>";
echo (is_file($realfile))? "<img src='file.jpg'/>" : "<img src='folder.jpg'/>";
echo "</td><td>" .filesize($realfile)."</td>";
echo "<td><input type='checkbox' name='delete[]'/></td></tr>";
}
?>
并且我将脚本放入配置文件页面,即确认DELETE(html表单):
<form method="post" action="delete.php" ecntype="multipart/form-data">
Please confirm if you wish to delete the selected files :
<input type="submit" value="Detele selected files" onclick="return confirm('DELETE the selected?');" />
以及delete.php:
<?php
if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
foreach($_POST['check_list'] as $selected)
{
unlink($selected);
}
}
}
include 'profile.php';
?>
不幸的是,它没有按照我想要的方式工作......很乐意得到一些帮助。 谢谢