我想检查文件夹是否为空,但不断收到此错误
警告:file_exists() 期望参数 1 为字符串,给定数组
if(!file_exists(glob('/upload/'.$id.'/temp/*'))){
$smeg = 'empty';
}
glob
返回array
类型。
像这样更改代码
foreach(glob('/upload/'.$id.'/temp/*') as $filename)
{
if(!file_exists($filename))
{
$smeg = 'empty';
}
}
来自 PHP 文档关于 glob()
:
返回一个包含匹配文件/目录的数组,一个空的 数组(如果没有匹配的文件)或错误时为 FALSE。
你必须循环结果
foreach(glob('/upload/'.$id.'/temp/*') as $file) {
if(!file_exists($file)){
$smeg = 'empty';
}
}