这是我得到的代码:
<?
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, '"/>';
现在,我想要链接的东西,所以它会导致更大的图像。
答案 0 :(得分:0)
您可以链接到图片<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>';
}
}
}