Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPScandir、readdir等没有显示文件列表,返回false,甚至使用了chmod-R0777_Php - Fatal编程技术网

PHPScandir、readdir等没有显示文件列表,返回false,甚至使用了chmod-R0777

PHPScandir、readdir等没有显示文件列表,返回false,甚至使用了chmod-R0777,php,Php,首先很抱歉,如果这个问题已经回答或者是另一个愚蠢的问题,请告诉我在哪里可以找到答案 今天,我使用scandir从另一个站点获取同一台机器的列表目录,但即使我运行了chmod-R 0777 fot it dir,也无法获取列表 # all bellow code run from site2.com $location = "/var/www/vhosts/site1.com/site1.com/httpdocs/webdata/"; # this return FALSE $files = s

首先很抱歉,如果这个问题已经回答或者是另一个愚蠢的问题,请告诉我在哪里可以找到答案

今天,我使用scandir从另一个站点获取同一台机器的列表目录,但即使我运行了chmod-R 0777 fot it dir,也无法获取列表

# all bellow code run from site2.com
$location = "/var/www/vhosts/site1.com/site1.com/httpdocs/webdata/";

# this return FALSE
$files = scandir($location);  # return FALSE
$res = opendir($location);
$files = readdir($res);  # return FALSE
closedir($res);

# i try this after chmod -R 0777 /var/www/vhosts/site1.com/site1.com/httpdocs/webdata/
# from terminal with admin account, but still ... FALSE :-(
print(is_readable($location) ? 'TRUE' : 'FALSE');  # print FALSE
我通过使用exec函数解决了这个问题,但似乎不推荐使用它,尤其是在cpanel上。问题是为什么我仍然不能得到chmod之后的函数返回true?从谷歌搜索和php it self没有解释为什么会发生这种情况,我已经找到了获取文件列表的方法,但我仍然想知道为什么在运行chmod-R0777之后会发生这种情况

注意:我是该机器的管理员,该机器上的所有网站都属于我,因此我不会尝试攻击任何客户端网站并使用ehcp托管控制面板

多谢各位

我喜欢它,这会导致在php设置或apache设置上受到“open_basedir”的限制


很抱歉。

您的文档根是什么?谢谢您的提示。我发现了这个问题,这是因为在php设置或apache设置上打开了basedir。