PHP 的file_exists为具有外语字符的文件名返回 false


php's file_exists is returning false for file name having foreign language characters

$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://添加到路径。