【发布时间】:2014-01-18 13:48:19
【问题描述】:
我想从名为 tempimages 的文件夹中删除所有超过 1 小时的图像。 我在 Stack Overflow 上找到了以下示例,但出现解析错误:
语法错误,第 13 行 /delete-old-images.php 中出现意外的“{”
<?php
function destroy($dir) {
$mydir = opendir($dir);
while($file = readdir($mydir)) {
if($file != "." && $file != "..") {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir('.');
while($dir.$file) {
if(date("U",filectime($file) >= time() - 3600)
{
unlink($dir.$file)
}
}
}
else
unlink($dir.$file) or DIE("couldn't delete $dir$file<br />");
}
}
closedir($mydir);
}
destroy("tempimages/");
?>
我的服务器数据:
PHP Version 5.3.18-nmm1
System Linux #116-Ubuntu SMP Tue Nov 12 19:37:57 UTC 2013 x86_64
Build Date Oct 26 2012 16:30:11
Server API Apache 2.0 Handler
如何解决?
【问题讨论】:
标签: php