【问题标题】:listing folders of parent directory with opendir does not work使用 opendir 列出父目录的文件夹不起作用
【发布时间】:2012-04-08 22:41:18
【问题描述】:

以下脚本适用于当前目录:

<?php    
$ignore = array ('.', '..', '.DS_Store', 'index.php');
    $num_ordnernamen = array ();
    if ($handle = opendir('./')) {
    while (false !== ($entry = readdir($handle))) {
        if (!in_array($entry, $ignore) && is_dir($entry)) {
        array_push($num_ordnernamen, $entry);
        }
    }
    }
    print_r ($num_ordnernamen); 
?>

,它按原样返回数组:

Array ( [0] => firstfolder [1] => secondfolder )

但是,它确实不适用于

if ($handle = opendir('../')) //or
if ($handle = opendir('..')) //or
if ($handle = opendir('../..'))

... 或任何我试图提升一级的东西。我在这里错过了什么?

【问题讨论】:

    标签: php parent opendir


    【解决方案1】:
    • 您有读取父目录的权限吗?
    • 您是否启用了错误报告功能?
    • 您的父目录中有目录吗? (您的代码仅打印目录)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 2013-03-16
      • 1970-01-01
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多