当查看页面或没有任何单击按钮时,如何实现自动删除文件夹中的所有文件,例如有人访问页面index.php,然后自动执行删除文件夹中的所有文件?
Try this code
$iterator = new FilesystemIterator($dir);
while($iterator->valid()) {
@unlink($dir.$filename);
}
$(function() {
$i=0;
$handle = opendir($dir);
while ($filename = readdir($handle))
{
if($filename!="."&&$filename!="..")
{
if(!is_dir($dir.$filename))
{
@unlink($dir.$filename);
}
else
del_cache($dir.$filename."/");
}
}
});
It is called when the page is loaded. There is no need to call function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.