【问题标题】:file_exists() return FALSEfile_exists() 返回 FALSE
【发布时间】:2017-08-15 17:38:21
【问题描述】:

我无法访问我的服务器中具有rw-r--r-- 权限的文件,file_exists() 函数总是返回FALSE 访问要更改什么?

【问题讨论】:

  • 用chmod 755 /path/to/file.txt更改权限
  • 有可能以某种方式使用 PHP 吗?我的脚本也在同一台服务器上运行。
  • 1.它是file_exists() 2. 它实际上应该返回true,对于权限检查有is_readable,所以检查你的文件路径,同时输出当前的dirname(__FILE__),看看路径相对于你的文件是否正确
  • 并检查 !is_dir 是否存在文件名以防万一
  • 确保您检查的路径正确。

标签: php file-permissions file-exists


【解决方案1】:

如果说php,函数实际上是file_exists(path)不是file_exist(),而file_exists()需要使用驱动器上的文件路径而不是URL。

所以你应该这样做:

$file = '/var/www/html/scripts/asset/some_file.png';
if(file_exists($file))
{
    //Will enter here if the file actually exists in that path
}

【讨论】:

  • 这是一个拼写错误,我确定使用了正确的函数名。
猜你喜欢
  • 2012-09-02
  • 2012-02-23
  • 2016-09-02
  • 2013-10-12
  • 1970-01-01
  • 1970-01-01
  • 2015-09-14
  • 2013-06-30
  • 2011-10-19
相关资源
最近更新 更多