PHP is_file()和file_exists()对于现有的PDF和SVG文件不返回true


PHP is_file() and file_exists() doesn't return true for existing PDF and SVG files

我不知道这是否是函数的内在属性或我的PHP配置中的某些东西,但由于某种原因,当我使用is_file()和file_exists()来确认PDF或SVG文件的存在与全局路径(/home/brian/public_html/path/to/file. PDF)然后它将返回false即使文件存在。

这些文件类型发生这种情况有什么原因吗?

马上遇到这个问题,除了使用fopen():

if ($file = @fopen($file_path, 'rb')): // returns resource id if file exists
   //do whatever you like!
else:
   //file does not exist
endif;

也许不是最干净的解决方案,但它适用于我