class fileEntity{ public $filename=null; public $is_dir=null; public function __construct($filename, $filetype) { $this->filename = $filename; $this->is_dir =$filetype; } } function listFile($path,$array_allow_file) { $result =array(); $TrackDir=opendir($path); while ($file = readdir($TrackDir)) { if ($file == "." || $file == "..") { } else { $extesion = end(explode('.', $file)); if (in_array($extesion, $array_allow_file) || is_dir($path.'/'.$file)) { $entity = new fileEntity($file, is_dir($path.'/'.$file)); array_push($result, $entity); } } } closedir($TrackDir); return $result; }
Thursday, February 16, 2012
List files and folders in the folder
Posted by
Unknown
at
4:52 PM
This is easy way to read all file and folder to array, this also check allow extestion file to read.
Subscribe to:
Post Comments (Atom)