如何在目录映像中包含链接


How do I include a link with my directory images?

这是我得到的一个代码:

<?
include "top.php";
?>
<center>
<a href='upload.php'><button>Upload Image</button></a>
</center>
<br>
<?php

$www_root = 'http://annexsecurity.x10.mx/images';
$dir = 'images/';
$file_display = array('jpg', 'jpeg', 'png', 'gif');
if ( file_exists( $dir ) == false ) {
   echo 'Directory ''', $dir, ''' not found!';
} 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)) ) {
          echo '<img src="', $www_root, '/', $file, '" alt="', $file, '"/>';
       }
    }
}
?>
<style type="text/css">
  img {
    height: 100;
    width: 100;
    float: left;
    margin: 0.5em;
    border: 1px solid #ccc;
    padding: 1em;
    font-size: 10px;
  }
</style>

我想做的是,当你点击图片时,它会引导你看到更大版本的图片。比如,完整的图像。例如,它会导致以下情况:http://www.example.com/image.png/

有人能帮我做这个吗?这是显示图像的代码行:

echo '<img src="', $www_root, '/', $file, '" alt="', $file, '"/>';

现在,我想要链接的东西在那里,这样它将导致更大的图像。

您可以链接到图像<a href="http://example.com/image.png"><img src="imageSrcHere" alt="" /></a>

if ( file_exists( $dir ) == false ) {
   echo 'Directory '''. $dir. ''' not found!';
} 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)) ) {
          $imageLink = 'http://example.com/image.png'; //please write image url here.
          echo '<a href="'.$imageLink.'"><img src="'. $www_root. '/'. $file. '" alt="'. $file. '"/></a>';
       }
    }
}