<?php $dir =basename(__DIR__); 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) == true) { echo '<img src="'.$dir. '/'.$file. '" alt="'.$file. '" />'; } } } ?>
<?php $format = '<img src="[FILE]"> [FILE]<br>'; chdir(dirname(__FILE__)); $files = glob("*.{jpeg,jpg,png,gif}", GLOB_BRACE); foreach ($files as $file) { if (is_file($file)) { echo str_replace('[FILE]', htmlspecialchars($file), $format); } } ?>
<?php $urlbase = dirname($_SERVER["SCRIPT_NAME"]); $ext = array("jpg", "gif", "png"); if ($handle = opendir(__DIR__)) { while (false !== ($entry = readdir($handle))) { $path_parts = pathinfo($entry); if(in_array($path_parts["extension"], $ext)){ echo "<img src='$urlbase/{$path_parts["basename"]}' alt='$entry' /><br/>"; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)