Give a path, get the image below her, and display the php code.
The code is as follows:
Function getAllDirAndFile ($ path)
{
If (is_file ($ path ))
{
If (isImage ($ path ))
{
$ Str = "";
$ Str. ='
';$ Str. ="
";$ Path = iconv ("gb2312", "UTF-8", $ path );$ Str. ="
| ". $ Path ." |
| ";$ Str. ="
";$ Str. ="
";
Echo $ str;
}
}
Else
{
$ Resource = opendir ($ path );
While ($ file = readdir ($ resource ))
{
If ($ file! = "." & $ File! = "..")
{
GetAllDirAndFile ($ path. "/". $ file );
}
}
}
}
Function isImage ($ filePath)
{
$ FileTypeArray = array ("jpg", "png", "bmp", "jpeg", "gif", "ico ");
$ FilePath = strtolower ($ filePath );
$ LastPosition = strrpos ($ filePath ,".");
$ IsImage = false;
If ($ lastPosition> = 0)
{
$ FileType = substr ($ filePath, $ lastPosition + 1, strlen ($ filePath)-$ lastPosition );
If (in_array ($ fileType, $ fileTypeArray ))
{
$ IsImage = true;
}
}
Return $ isImage;
}