dourong4031 2013-12-21 20:14
浏览 83
已采纳

无法包含现有文件 - 无法打开流:权限被拒绝

this is not a duplicate question, I read all related questions, and didn't find my answer.

I want to include a file that exists :

/var/www/html/monitor/protected/extensions/curl/curl.php

and my code is :

include('/monitor/protected/extensions/curl/curl.php');

and I'm getting this error :

include(/var/www/html/monitor/protected/extensions/curl/curl.php): failed to open stream: Permission denied

and the file has 777 permission.

My question is :

is it possible that a file exists and have a 777 permission and a proper chown AND still give this error?

Update : I had used all three possible ways :

  1. include('/monitor/protected/extensions/curl/curl.php');

  2. include('monitor/protected/extensions/curl/curl.php');

  3. include('/var/www/html/monitor/protected/extensions/curl/curl.php');

Im using php 5.3

Note: when including another file in the same directory, it includes without any problem

  • 写回答

3条回答 默认 最新

  • doujunchi1238 2013-12-21 20:24
    关注

    You're using the wrong path. If the file exists at

    /var/www/html/monitor/protected/extensions/curl/curl.php
    

    Then you should include that exact string.

    include('/var/www/html/monitor/protected/extensions/curl/curl.php');
    

    / means the root of the file system. You get permission denied because you most certainly don't have permission to / and /monitor doesn't exist

    Alternatively you can include it relatively. By dropping the first / you would do:

    include('monitor/protected/extensions/curl/curl.php');
    

    This will work if the running script is also in /var/www/html.

    I think you're getting confused at the difference between the HTTP path and the system path. PHP files are included from the system path and should be referenced by the system path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配