-1

フォルダーへのリンクを生成するための php スクリプト/ページのヘルプが必要です。Lightroom を使用してアップロードした写真を含むホームページを用意し、各アルバムを個別のフォルダーに入れます。

構造は次のとおりです。

mysite.com  
  |--images  
    |--folder1  
    |--folder2  
    |--folder3  
    .  
    . 

したがって、mysite.com のルートにある静的な index.html ファイルの代わりに、「images」のすべてのサブフォルダーへのリンクを生成する動的な index.php ファイルを作成したいと考えています。

<html>
  <body>
    <a href="mysite.com/images/folder1" target="_blank">folder1</a>
    <a href="mysite.com/images/folder2" target="_blank">folder2</a>
    <a href="mysite.com/images/folder3" target="_blank">folder3</a>
    .
    .
  </body>
</html>

事前にサンクス

4

3 に答える 3

1
<?php
    $files = scandir();
    $dirs = array(); // contains all your images folder
    foreach ($files as $file) {
        if (is_dir($file)) {
           $dirs[] = $file;
        }
    }
?>

リンクを動的に生成するためにdirs配列を使用する

于 2013-07-20T02:09:14.360 に答える
0

多分このようなもの:

$dir = "mysite.com/images/";
$dh = opendir($dir);
while ($f = readdir($dh)) {
  $fullpath = $dir."/".$f;
  if ($f{0} == "." || !is_dir($fullpath)) continue;
  echo "<a href=\"$fullpath\" target=\"_blank\">$f</a>\n";
}
closedir($dh);

すべてが必要な場合(つまりsomething/*、.readdir()glob()

私が間違っていなければ、ファイルをglob()省略し、変数を必要としないので、速度を求めている場合は、いくつかのテストを行うことをお勧めします。.*$fullpath

于 2013-07-20T02:15:45.513 に答える