当文件名为非拉丁语言时,PHP: file_exists don'不起作用


PHP: file_exists don't work when file name is in non-latin language

我有以下代码

    $file = WWW_ROOT."/upload/files/".$id.".plist";
/* $file=iconv('utf-8', 'latin1', $file); */
/*  print_r($file);exit; */
if (file_exists($file)) {
  //downloading
}

问题发生在$id有类似جدة的东西时,它找不到文件,尽管它存在。我可以在代码中添加什么来将$id转换为utf-8并读取磁盘上的文件?

不要移除iconv…你需要这样的东西....

$id = "file_å";
$file = __DIR__ . "/" . $id . ".plist";
$file = iconv('utf-8', 'cp1252', $file);
/* print_r($file);exit; */
if (file_exists($file)) {
    // downloading
    print("OK");
}