加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php 删除一组文件的简单示例

发布时间:2020-05-26 00:17:51 所属栏目:PHP 来源:互联网
导读:php 删除一组文件的简单示例

对php删除一组文件感兴趣的小伙伴,下面一起跟随脚本之家 jb51.cc的小编两巴掌来看看吧!
在web开发中经常会有选择多个内容进行操作的情况,我们看下php如何删除一组文件的。
form.html


<!-- These files must exist to work (This is only an example) -->
<form action="process.php" method="post">
<input type="checkbox" value="file1.html" name="delete[]"> file1.html<br>
<input type="checkbox" value="file2.html" name="delete[]"> file2.html<br>
<input type="checkbox" value="file3.html" name="delete[]"> file3.html<br>
<input type="submit" value="Delete Selected" name="submit">
</form>

process.php

/**
 * php删除一组文件
 *
 * @param 
 * @arrange 512-笔记网: www.512Pic.com
 **/
<?php
# Take each checked value,and give it a name of $delete
foreach($_POST['delete'] as $delete){
# Make sure the file actually exists
if(file_exists("/location/of/directory/".$delete)){
# Delete each file
unlink("/location/of/directory/",$delete);
}else{
continue;
}
}
# Return to form.html
header("Location: form.html");

/***   来自脚本之家 jb51.cc(jb51.cc)   ***/

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读