PHP Read Directory Image file This is a PHP read directory like file Oh, code, he used the Opendir to open the directory and then get the file suffix name, determine whether the specified file.
PHP Tutorial Read directory image file
This paragraph is a PHP read directory like file Oh, code, he used the Opendir to open the directory and then get the file suffix name, determine whether the specified file.
*/
$directory = ' gallery ';
$allowed _types=array (' jpg ', ' jpeg ', ' gif ', ' PNG ');
$file _parts=array ();
$ext = ";
$title = ";
$i = 0;
$dir _handle = @opendir ($directory) or Die ("There is a error with your image directory!");
while ($file = Readdir ($dir _handle))
{
if ($file = = '. ' | | $file = = ' ... ') continue;
$file _parts = Explode ('. ', $file);
$ext = Strtolower (Array_pop ($file _parts));
$title = Implode ('. ', $file _parts);
$title = Htmlspecialchars ($title);
$nomargin = ";
if (In_array ($ext, $allowed _types))
{
if (($i + 1)%4==0) $nomargin = ' Nomargin ';
Echo '
'. $title. '
';
$i + +;
}
}
Closedir ($dir _handle);
http://www.bkjia.com/PHPjc/633023.html www.bkjia.com true http://www.bkjia.com/PHPjc/633023.html techarticle PHP Read directory image file This is a PHP read directory like file Oh, code, he used the Opendir to open the directory and then get the file suffix name, to determine whether the specified file ...