这篇文章主要为大家详细介绍了php 删除一组文件的简单示例,具有一定的参考价值,可以用来参考一下。
对php删除一组文件感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
<!-- 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.q1010.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");
/*** 来自四海网(www.q1010.com) ***/
本文来自:http://www.q1010.com/173/1125-0.html
注:关于php 删除一组文件的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:删除文件
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。