Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- scanDirectoryImages('.');
- function scanDirectoryImages($directory) {
- if (substr($directory, -1) == '/') {
- $directory = substr($directory, 0, -1);
- }
- if (!file_exists($directory) || !is_dir($directory)) {
- return FALSE;
- }
- else if (is_readable($directory)) {
- $directory_tree = array();
- $directory_list = opendir($directory);
- while($file = readdir($directory_list)) {
- if ($file != '.' && $file != '..') {
- $path = $directory . '/' . $file;
- if (is_readable($path)) {
- $subdirectories = explode('/', $path);
- if (is_dir($path)) {
- scanDirectoryImages($path);
- }
- else if (is_file($path)) {
- $extension = end(explode('.', end($subdirectories)));
- if (in_array($extension, array('jpeg', 'jpg', 'gif', 'png'))) {
- echo '<a href="' . $path . '"><img src="' . $path . '" style="max-height: 100px; max-width: 100px;" /></a>';
- }
- }
- }
- }
- }
- closedir($directory_list);
- }
- else {
- return FALSE;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement