【问题标题】:Php photo displayphp图片展示
【发布时间】:2013-09-11 13:06:32
【问题描述】:

我目前已使用 php 将我目录中的文件夹中的图像显示到屏幕上,如下所示:

$file_display = array('jpg', 'jpeg', 'png', 'gif');

$dir = 'images';

if (file_exists($dir) == false)
{
    echo 'Doesnt exist';
}
else
{
    $dir_contents = scandir($dir);

    foreach ($dir_contents as $file)
    {
        $file_type = strtolower (end (explode('.', $file)));

        if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true)
        {
            echo '<img src="', $dir, '/', $file, '" alt="', $file,'" />';
        }  
    }
}

我为屏幕尺寸设置了 600 像素的宽度。我现在尝试将这些图像显示在屏幕下方的 4 列中,并要求所有图像大小相同。

有人对如何做到这一点有任何想法吗?

【问题讨论】:

    标签: php gallery photo


    【解决方案1】:

    试试这个:

    echo '<img src="'.$dir.'/'.$file.'" alt="'.$file.'" width="600px" />';
    

    【讨论】:

    • 谢谢 :) 如果我想单击其中一张图片以在弹出窗口中显示该完整图片,我将如何实现?
    猜你喜欢
    • 2011-08-30
    • 2020-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多