1<?php
2function rasmname(){
3 $dirname = "./";
4 $images = glob($dirname."*.jpg");
5foreach($images as $image) {
6 echo '<img src="'.$image.'" /><br />';
7 }
8}
9rasmname();
1<?php
2
3echo scanDirectoryImages("uploads");
4
5/**
6* Recursively search through directory for images and display them
7*
8* @param array $exts
9* @param string $directory
10* @return string
11*/
12function scanDirectoryImages($directory, array $exts = array('jpeg', 'jpg', 'gif', 'png'))
13{
14if (substr($directory, -1) == '/') {
15 $directory = substr($directory, 0, -1);
16}
17$html = '';
18if (
19 is_readable($directory)
20 && (file_exists($directory) || is_dir($directory))
21) {
22 $directoryList = opendir($directory);
23 while($file = readdir($directoryList)) {
24 if ($file != '.' && $file != '..') {
25 $path = $directory . '/' . $file;
26 if (is_readable($path)) {
27 if (is_dir($path)) {
28 return scanDirectoryImages($path, $exts);
29 }
30 if (
31 is_file($path)
32 && in_array(end(explode('.', end(explode('/', $path)))), $exts)
33 ) {
34 $html .= '<a href="' . $path . '"><img src="' . $path
35 . '" style="max-height:100px;max-width:100px" /> </a>';
36 }
37 }
38 }
39 }
40 closedir($directoryList);
41}
42return $html;
43}
1<html>
2 <head>
3 <title>display image</title>
4 </head>
5 <body>
6 <p>Here in your form and text</p>
7 <?php
8
9 echo "<img src='image-name.png' >";
10
11 ?>
12 </body>
13 </html>