微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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)   ***/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐