【发布时间】:2014-02-17 06:37:45
【问题描述】:
我想检查文件是否存在并显示定义的图像。我尝试使用如下代码。即使存在 1111.pdf,它也始终只显示 no.png!
$fileUrl = "http://localhost/Report/1111.pdf";
$AgetHeaders = @get_headers($sourcePath);
if (preg_match("|200|", $AgetHeaders[0])) {
// file exists
echo "<img src='http://localhost/Report/yes.png'>";
} else {
// file doesn't exists
echo "<img src='http://localhost/Report/no.png'>";
}
【问题讨论】:
标签: php