$file_name = "x:/htdocs/host/sales_documents/testvilkår, webhotell og domenenavn_2ccda.pdf";
if(!file_exists($file_name))
{
echo "<h2>404 Error</h2>";
exit;
}
文件名是一个有效的文件,它也确实存在,但仍然file_exists
返回false
。
你能告诉我它背后的原因是什么吗?
检查您的文件路径。 你的代码没问题。
将斜杠更改为常量DIRECTORY_SEPARATOR
并将file://
添加到路径。