Copy codeThe Code is as follows:
Function getAllDirAndFile ($ path)
{
If (is_file ($ path ))
{
If (isImage ($ path ))
{
$ Str = "";
$ Str. = '<table style = "border: solid 1px blue;" width = "95%"> ';
$ Str. = "<tr> ";
$ Path = iconv ("gb2312", "UTF-8", $ path );
$ Str. = "<td width = 80%> ". $ path. "</td> <td width = 15%> </td> ";
$ Str. = "</tr> ";
$ Str. = "</table> ";
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;
}