【问题标题】:file exists but I cannot open it using php文件存在,但我无法使用 php 打开它
【发布时间】:2015-10-22 04:35:07
【问题描述】:

我可以使用 vim 命令打开和写入文件,但我无法使用 PHP 打开它

$myFile = "v.txt"; 
if(!file_exists($myFile)){
    print 'File not found';
}else if(!$fh = fopen($myFile, 'w+')){
    print 'Can\'t open file \n';}.
else{  
    print 'Success open file';
}

【问题讨论】:

  • 我用的是自己的linux服务器
  • 也许该文件需要或需要root权限或某种特权才能让某些用户修改或读取文件?
  • 确保该文件具有为www-data用户写入的权限
  • 检查日志并确保报告了 E_WARNING:php.net/manual/en/…

标签: php linux apache file


【解决方案1】:

做一个

ls -l

在包含该文件的目录上。确保运行您的网络服务器的用户对文件具有访问读取权限

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 1970-01-01
    • 2015-01-04
    相关资源
    最近更新 更多