澳门威利斯人_威利斯人娱乐「手机版」

来自 办公软件 2019-09-28 22:16 的文章
当前位置: 澳门威利斯人 > 办公软件 > 正文

读取文件夹文件函数,读取目录文件夹列表程序

php 读取文件夹文件函数

function getfolders( $resourcetype, $currentfolder )
{
 // map the virtual path to the local server path.
 $sserverdir = servermapfolder( $resourcetype, $currentfolder, 'getfolders' ) ;

php 读取目录文件夹列表程序

function GetFoldersAndFiles( $resourceType, $currentFolder )
{
 // Map the virtual path to the local server path.
 $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ;

 // array that will hold the folders names.
 $afolders = array() ;

function GetFolders( $resourceType, $currentFolder )
{
 // Map the virtual path to the local server path.
 $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ;

 // Arrays that will hold the folders and files names.
 $aFolders = array() ;
 $aFiles  = array() ;

 $ocurrentfolder = opendir( $sserverdir ) ;

 // Array that will hold the folders names.
 $aFolders = array() ;

 $oCurrentFolder = opendir( $sServerDir ) ;

 while ( $sfile = readdir( $ocurrentfolder ) )
 {
  if ( $sfile != '.' && $sfile != '..' && is_dir( $sserverdir . $sfile ) )
   $afolders[] = '<folder name="' . converttoxmlattribute( $sfile ) . '" />' ;
 }

 $oCurrentFolder = opendir( $sServerDir ) ;

 while ( $sFile = readdir( $oCurrentFolder ) )
 {
  if ( $sFile != '.' && $sFile != '..' )
  {
   if ( is_dir( $sServerDir . $sFile ) )
    $aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
   else
   {
    $iFileSize = @filesize( $sServerDir . $sFile ) ;
    if ( !$iFileSize ) {
     $iFileSize = 0 ;
    }
    if ( $iFileSize > 0 )
    {
     $iFileSize = round( $iFileSize / 1024 ) ;
     if ( $iFileSize < 1 ) $iFileSize = 1 ;
    }

 closedir( $ocurrentfolder ) ;

 while ( $sFile = readdir( $oCurrentFolder ) )
 {
  if ( $sFile != '.' && $sFile != '..' && is_dir( $sServerDir . $sFile ) )
   $aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
 }

    $aFiles[] = '<File name="' . ConvertToXmlAttribute( $sFile ) . '" size="' . $iFileSize . '" />' ;
   }
  }
 }

 // open the "folders" node.
 echo "<folders>" ;

 closedir( $oCurrentFolder ) ;

 // Send the folders
 natcasesort( $aFolders ) ;
 echo '<Folders>' ;

 natcasesort( $afolders ) ;
 foreach ( $afolders as $sfolder )
  echo $sfolder ;

 // Open the "Folders" node.
 echo "<Folders>" ;

 foreach ( $aFolders as $sFolder )
  echo $sFolder ;

 // close the "folders" node.
 echo "</folders>" ;
}

 natcasesort( $aFolders ) ;
 foreach ( $aFolders as $sFolder )
  echo $sFolder ;

 echo '</Folders>' ;

function getfoldersandfiles( $resourcetype, $currentfolder )
{
 // map the virtual path to the local server path.
 $sserverdir = servermapfolder( $resourcetype, $currentfolder, 'getfoldersandfiles' ) ;

 // Close the "Folders" node.
 echo "</Folders>" ;
}

 // Send the files
 natcasesort( $aFiles ) ;
 echo '<Files>' ;

 // arrays that will hold the folders and files names.
 $afolders = array() ;
 $afiles  = array() ;

 foreach ( $aFiles as $sFiles )
  echo $sFiles ;

 $ocurrentfolder = opendir( $sserverdir ) ;

 echo '</Files>' ;
}

 while ( $sfile = readdir( $ocurrentfolder ) )
 {
  if ( $sfile != '.' && $sfile != '..' )
  {
   if ( is_dir( $sserverdir . $sfile ) )
    $afolders[] = '<folder name="' . converttoxmlattribute( $sfile ) . '" />' ;
   else
   {
    $ifilesize = @filesize( $sserverdir . $sfile ) ;
    if ( !$ifilesize ) {
     $ifilesize = 0 ;
    }
    if ( $ifilesize > 0 )
    {
     $ifilesize = round( $ifilesize / 1024 ) ;
     if ( $ifilesize < 1 ) $ifilesize = 1 ;
    }

    $afiles[] = '<file name="' . converttoxmlattribute( $sfile ) . '" size="' . $ifilesize . '" />' ;
   }
  }
 }

 // send the folders
 natcasesort( $afolders ) ;
 echo '<folders>' ;

 foreach ( $afolders as $sfolder )
  echo $sfolder ;

 echo '</folders>' ;

 // send the files
 natcasesort( $afiles ) ;
 echo '<files>' ;

本文由澳门威利斯人发布于办公软件,转载请注明出处:读取文件夹文件函数,读取目录文件夹列表程序

关键词: 澳门威利斯人