$filename = '/www/test1/*.pdf';
if (file_exists($filename))
{
echo "The file $filename exists";
}
else
{
echo "The file $filename does not exist";
}
我使用了上面的代码,但它检查了 *.pdf 文件,但没有检查所有属于 .pdf 扩展名的文件
最佳答案
$filename = '/www/test1/*.pdf';
if (count(glob($filename)) > 0) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
关于php - 如何仅使用扩展名(*.pdf)检查文件是否存在于 php 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16813961/