ecshop如何解决readdir(): not a valid Directory resource in报错
有客户ecshop网站程序在ecshop后台---模板管理*---模板选择顶部出现以下报错:
Warning: readdir(): supplied argument is not a valid Directory resource in zuimobanecshopadmintemplate.php on line 66
是第一次看到,看看代码,才知道原因,我们找admintemplate.php找到66行看代码:
- $tmp_bak_dir = @opendir(ROOT_PATH . 'temp/backup/library/');
- while ($file = readdir($tmp_bak_dir))
- {
- if ($file != '.' && $file != '..' && $file != '.svn' && $file != 'index.htm' && is_file(ROOT_PATH .'temp/backup/library/' . $file) == true)
- {
- $code = substr($file, 0, strpos($file, '-'));
- if (!in_array($code, $available_code))
- {
- @unlink(ROOT_PATH . 'temp/backup/library/' . $file);
- } //开源软件:phpfensi.com
- }
- }
该段代码意思 读取temp/backup/library/ 文件夹以及文件,若该文件夹不存在,就会readdir():