【问题标题】:php's file_exists is returning false for file name having foreign language charactersphp 的 file_exists 为具有外语字符的文件名返回 false
【发布时间】:2013-07-04 08:16:51
【问题描述】:
$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
你能告诉我它背后的原因是什么吗?

【问题讨论】:

  • Unix 还是 Windows?尝试过反斜杠吗?
  • 尝试用 {} 括起来文件名
  • 您找到解决方案了吗?我有一个类似的问题,有一个“,”和一个相邻的空格,这让我很烦恼。

标签: php file-exists


【解决方案1】:

检查您的文件路径。你的代码没问题。

【讨论】:

    【解决方案2】:

    将斜杠更改为常量DIRECTORY_SEPARATOR 并将file:// 添加到路径中。

    【讨论】:

      猜你喜欢
      • 2015-09-14
      • 2012-09-02
      • 2018-12-15
      • 1970-01-01
      • 2011-06-05
      • 2014-01-02
      • 2016-01-13
      • 2015-05-27
      • 2017-08-15
      相关资源
      最近更新 更多