php - 仅删除选中的文件和文件夹

时间:2015-12-05 17:12:40

标签: php

第一次,希望得到一些帮助:

我正在尝试创建一个以确认“按钮”开头的delete.php脚本,并仅删除所选/选择复选框/文件和/或文件夹(包括其中的文件)

到目前为止,这是我的代码:

<style>
td, th {border:2px solid gray; padding:2 30px;}
</style>
<form method="post" action="upload_file.php" enctype="multipart/form-data">
Select file: <input type="file" name="imeNaFile">
<input type="submit" value="Upload">
</form>
<table>
<tr>
<th>Filename</th>
<th>Type</th>
<th>Size</th>
<th>Delete:</th>
</tr>

<?php 
$path = ".";
$dh = dir($path);
while( ($file=$dh->read()) ) 
{
   if( $file=="." || $file=="..")continue;
   echo "<tr><td><a href='download.php?f=$file' title='Click to Open/Download'>$file</a></td>";
   echo "<td>";
   echo (is_file($file))? " F ": " D ";
   echo "</td><td>" .filesize($file)."</td>";
   echo "<td><input type='checkbox' name='delete[]'/></td>";
}
?>
</table>
<form method="post" action="delete.php" ecntype="multipart/form-data">
Please confirm if you wish to delete the selected files 
<input type="button" value="Detele selected files" onclick="return confirm('DELETE the selected?');" />
</form>
`

0 个答案:

没有答案