2011-09-08 8 views
0

ディレクトリスキャンからLINKに適切に読み込まれたリンクを取得できないようです。私が人口リンクをクリックすると、現在孫のディレクトリではなく現在のディレクトリを参照しています。ここではdir_2/dir_3です。どんな助けでも大歓迎です。孫ディレクトリのファイルを現在のディレクトリからPHP opendirで2レベル下にリンクするにはどうすればいいですか?

<?php 

    // These files will be ignored 
    $excludedFiles = array (
'excludeMe.file', 
'excludeMeAs.well' 
); 

// These file extensions will be ignored 
$excludedExtensions = array (
    'html', 
'xslt', 
'htm', 
'ahk', 
'xsl', 
'txt', 
'xml' 
); 

// Make sure we ignore . and .. 
$excludedFiles = array_merge($excludedFiles,array('.','..')); 

// Convert to lower case so we are not case-sensitive 
for ($i = 0; isset($excludedFiles[$i]); $i++) $excludedFiles[$i] =   
strtolower(ltrim($excludedFiles[$i],'.')); 
    for ($i = 0; isset($excludedExtensions[$i]); $i++) $excludedExtensions[$i] =  
strtolower($excludedExtensions[$i]); 

    // Loop through directory 
    $count = 0; 
    if ($handle = opendir('dir_2/dir_3')) { 
    while (false !== ($file = readdir($handle))) { 
    $extn = explode('.',$file); 
    $extn = array_pop($extn); 
    // Only echo links for files that don't match our rules 
    if (!in_array(strtolower($file),$excludedFiles) && 
    !in_array(strtolower($extn),$excludedExtensions)) { 
    $count++; 
    print("<a href=\"".$file."\">".$file."</a><br />\n"); 
    } 
} 
echo '<br /><br /><a href="..">Return</a>'; 
closedir($handle); 
} 

?> 

答えて

0

あなたが探しているディレクトリをリンクに追加する必要があります。

$dir = 'dir_2/dir_3'; 
if ($handle = opendir($dir)) { 
// snip 
print("<a href=\"".$dir.$file."\">".$file."</a><br />\n"); 
+0

私はエラーをのgettinています - 解析エラー:構文エラー、ライン172上の/home/content/65/7238265/html/Reports/dropdown.phpで予期しないT_VARIABLE - このライン - 印刷(」".$file."
を\ n "); – mikenichols

+0

おっと、児童童、その1:Pもう一度コピーすると、$ dirの前にコンカット(。)がありませんでした:) – Joe

+0

すごくうれしいです。 – mikenichols

関連する問題