php - unlink()删除带有复选框

时间:2015-12-27 17:47:18

标签: php file download directory

节日快乐。 我正在开发一个小型学校项目,需要使用复选框文件/文件夹删除所选项目。我得到这个PHP脚本给出特定文件的复选框:

<?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';
?>

不幸的是,它没有按照我想要的方式工作......很乐意得到一些帮助。 谢谢

0 个答案:

没有答案
相关问题