file_exists()
即使提供要检查的图像存在,我也会返回 false https://www.google.pl/logos/2012/haring-12-hp.png
。为什么?
下面我将展示准备在 localhost 上触发的完整失败的 PHP 代码:
$filename = 'https://www.google.pl/logos/2012/haring-12-hp.png';
echo "<img src=" . $filename . " />";
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}