0

我是 PHP 新手,我的 linux 服务器上有存储库,托管 web 的地方。

我有图像文件夹,例如 /myfolder/image1-user 等。我想在我的门户网站相册上显示它。我怎样才能做到这一点?

编辑 我已经迭代了存储图片的目录。现在我有图像路径的数组列表,我使用 IMG SRC 标记来显示,但没有显示任何内容,我还想要存储库中包含照片的每个文件的 URL,我有这样的图像链接 /myrepo/照片/photos-1/1.jpg 等等

4

2 回答 2

1

您必须遍历存储图像的文件夹。

    <?php

if ($handle = opendir('/path/to/files')) {
    echo "Directory handle: $handle\n";
    echo "Entries:\n";

    /* This is the correct way to loop over the directory. */
    while (false !== ($entry = readdir($handle))) {
        echo "$entry<br/>";
    }

    closedir($handle);
}
?>
于 2012-09-26T16:25:50.003 回答
0

symlink!

Say you want to display from your web root, e.g. /imgs/photos and your document root is the default '/var/www'

Then symlink that to the real folder below the webroot, for example:

ln -s /real/path/to/my/photos /var/www/imgs/photos (on command line)

Then, when in your html you use src="/imgs/photos/great-photo.jpg" it will display "/real/path/to/my/photos/great-photo.jpg"

This may not work if you're on a shared hosting virtual server environment with all kinds of restrictions (such as open basedir etc.)

于 2015-02-17T01:22:19.000 回答