Php functions for reading files in folders and folders
/**
- * Functions used to read folders and files
- * Edit: bbs.it-home.org
- *
- */
- Function GetFoldersAndFiles ($ resourceType, $ currentFolder)
- {
- // Map the virtual path to the local server path.
- $ SServerDir = ServerMapFolder ($ resourceType, $ currentFolder, 'getfoldersandfiles ');
// Arrays that will hold the folders and files names.
- $ AFolders = array ();
- $ AFiles = array ();
$ OCurrentFolder = opendir ($ sServerDir );
While ($ sFile = readdir ($ oCurrentFolder ))
- {
- If ($ sFile! = '.' & $ SFile! = '..')
- {
- If (is_dir ($ sServerDir. $ sFile ))
- $ AFolders [] =' ';
- Else
- {
- $ IFileSize = @ filesize ($ sServerDir. $ sFile );
- If (! $ IFileSize ){
- $ IFileSize = 0;
- }
- If ($ iFileSize> 0)
- {
- $ IFileSize = round ($ iFileSize/1024 );
- If ($ iFileSize <1) $ iFileSize = 1;
- }
$ AFiles [] =' ';
- }
- }
- }
// Send the folders
- Natcasesort ($ aFolders );
- Echo' ';
Foreach ($ aFolders as $ sFolder)
- Echo $ sFolder;
Echo'';
// Send the files
- Natcasesort ($ aFiles );
- Echo' ';
Foreach ($ aFiles as $ sFiles)
- Echo $ sFiles;
Echo'';
- }
Articles you may be interested in: php traverses the folder and implements code editing and deletion. php obtains the folder size. Php deletes the specified file and folder. PHP traverses the file and folder. small example. php retrieves the folder information. statistical function. php calculates the specified folder information (number of folders, number of files, folder size) code php traverses all files and subfolders under the Directory code php traverses the folder and all files under the code to calculate the php code of the folder size |