sloppycode.net
FileSystem class
A PHP file system class modelled on FSO
Home
›
Code snippets
›
PHP
›
FileSystem class
Download source + documentation
The FileSystem class is based on the File System Object COM object that is available for (classic) ASP/Windows in general.
This class like all PHP classes on sloppycode.net was made in PHP 3.x or 4, so unfortunately isn't guaranteed to be error free anymore.
<html> <head> <style> td { font-family:Arial;font-size:10pt} </style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="500"> <? set_time_limit(21600); include("clsFileSystem.php"); $startdir = $DOCUMENT_ROOT; $fso = new FileSystem(); /* -- Single file example ------------------------------*/ $singlefile = $fso->getFile($DOCUMENT_ROOT."/example.php"); echo "<TR><TD colspan=3><b>Single file :</b><BR>"; echo "Name :".$singlefile->name."<BR>"; echo "Last changed :".$singlefile->lastchanged."<BR>"; echo "Last accessed :".$singlefile->lastaccessed."<BR>"; echo "Last modified :".$singlefile->lastmodified."<BR>"; echo "Path :".$singlefile->path."<BR>"; echo "Extension :".$singlefile->extension."<BR>"; echo "Group :".$singlefile->group."<BR>"; echo "Owner :".$singlefile->owner."<BR>"; echo "Type :".$singlefile->type."<BR>"; echo "Size :".$singlefile->size."<BR><HR size=1 noshade color=black>"; echo "</TD></TR>"; /* -- Folders + files example ---------------------------------------- */ $folder = $fso->getFolder($startdir); // Display files for this folder $files = $folder->files; if (sizeof($files) >0) { foreach ($files as $filedata) { echo "<TR>\n"; echo "<TD>".$filedata->name."</TD>\n"; echo "<TD>".$filedata->size."KB</TD>\n"; echo "<TD>".strtoupper($filedata->extension)." FILE</TD>\n"; echo "<TD>".$filedata-->lastmodified." </TD>\n"; echo "</TR>\n"; } } // Display subfolders $subfolders = $folder->subfolders; foreach ($subfolders as $folderdata) { // Each of these subfolders is a folder object echo "<TR>\n"; echo "<TD>".$folderdata->name."</TD>\n"; echo "<TD> </TD>\n"; echo "<TD>File Folder</TD>\n"; echo "<TD>".$folderdata->lastmodified."</TD>\n"; echo "</TR>\n"; flush(); /* You could make it go a level deeper as below, or recurse * But be warned, it is likely to crash php if the folder * contains large amounts of file and subdirectories */ /* $thisfolder = $fso->getFolder($startdir.$folderdata->name); $thissubfolders = $thisfolder->subfolders; if (sizeof($thissubfolders) > 0) { foreach ($thissubfolders as $folderdata2) { echo "<TR>\n"; echo "<TD>".$folderdata2->name."</TD>\n"; echo "<TD> </TD>\n"; echo "<TD>File Folder</TD>\n"; echo "<TD>".$folderdata2->lastmodified."</TD>\n"; echo "</TR>\n"; } }*/ flush(); } ?> </TABLE> </body> </html>
{Name}
Says:
{Date}
{Text}
› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search
› Sitemap
Buy on Amazon
Buy on Amazon
Buy on Amazon
Buy on Amazon