【问题标题】:PHP fopen returns 403 Forbidden with HTTPSPHP fopen 返回 403 Forbidden with HTTPS
【发布时间】:2017-01-08 10:55:47
【问题描述】:

我在一个带有 Linux、Apache 和 php 5.2.17 且 allow_url_fopen=true 的托管站点上,一个 php 页面使用 fopen (fopen($_SESSION['IMG_DIR_REL']."/ img/img5.jpg", "rb")); 我不使用 file_exists 因为它返回 "nothing" :-( . 该页面位于子目录 ./test/ 上,图像位于子目录 ./img/ 上 如果我使用 http (http://www.example.com/test/control.php) 访问该页面,则 fopen 可以完美地提供正确的图像存在。 但是,如果我使用 https (https://www.example.com/test/control.php) 访问同一页面,我得到 fopen(https://www.example.com/img/img5.jpg) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 禁止。 如果我改为 fopen (fopen("../img/img5.jpg", "rb"));它适用于https。 我用谷歌搜索了一下,测试了一些类似案例的例子,但没有任何效果。 你有什么建议吗? 提前致谢。

【问题讨论】:

    标签: php https fopen


    【解决方案1】:

    这很可能意味着 Apache 无权访问“/img/img5.jpg”。

    如果是这种情况,您需要更改文件的权限或所有权。

    确保文件的所有者是运行服务器的组的一部分。

    Apache 默认在 httpd 组上运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 2012-08-26
      • 1970-01-01
      相关资源
      最近更新 更多