How do I list imags from directory?

aymail9

New Member
I'm trying to show all images within a specified directory.The following code lists all allowed file names:\[code\] function getDirectoryList() { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($this->currentDIR); // open directory and walk through the filenames while ($file = readdir($handler)) { // Make sure we get allowed images types if ($this->allowedFileType($file,$this->allowedImageTypes) ) { $results[] = $file; } } // tidy up: close the handler closedir($handler); // done! return $results; } (...) $images = getDirectoryList(); foreach($images as $img) { echo "<li>".$img."</li>"; } \[/code\]How can I get file size and MIME type?I read that \[code\]mime_content_type\[/code\]is deprecated and I should use finfo_file istead. But I've not been very successfull with this.Do I have to use \[code\]/usr/share/misc/magic\[/code\] to get file information? Can't I use GD library?I've looked at many examples, but they are old and don't work that well.Any help appreciated.
 
Back
Top