PHP file_exists在文档根目录外部不起作用 [英] PHP file_exists not working outside document root

查看:100
本文介绍了PHP file_exists在文档根目录外部不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下目录结构,其中文档根目录指向/var/www/html/public:

I have the following directory structure where the Document Root is pointed to /var/www/html/public:

  • /应用
  • /应用程序/控制器
  • /public(文档根目录)

我正在尝试使用以下代码检查/public目录中文件中是否存在文件(在本地安装程序上工作,但在实时服务器上不工作)

I am trying to use the following code to check if a file exists inside a file in the /public directory (working on local setup, but not on live server)

<?php 
if (file_exists('../application/controllers/TestController.php'))
{
    /* do something */
}

我需要添加的Apache配置文件中是否有内容?我不确定从这里要去哪里.

Could there be something in the Apache config file the I need to add? I am not sure where to go from here.

推荐答案

因此,我发现的真正问题是在实时服务器上,将文件重命名为小写(APIController => ApiController)后,文件名没有更改.即使更改发生在本地,提交代码时,我的GIT提交也没有正确重命名文件.

So the real problem that I found was that on my live server, the file name did not change when I renamed it to lowercase (APIController => ApiController). Even though the change happened locally, my GIT commit did not rename the file properly when the code was committed.

很抱歉造成混乱!

这篇关于PHP file_exists在文档根目录外部不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆