Displaying images based on list of file types?

Ty44ler's Avatar, Join Date: Jun 2009
Newbie Member
What I'm trying to do:
I am calling a list of file names from a folder and I'm trying to display a little icon next to it based on it's file type. Also I'm calling sub-folder names and trying to display an image of a folder next to that.

What is going wrong:
None of my images are showing up next to the file that is called. Also, folders are listed but the folder icon is not displayed next to it.

Any ideas? I'm really new to this, so if you could explain things like you would to a small child that would be great. Thanks!

Code: text
$ignore = array(".","..","FTPCss.css","images","Thumbs.db");
$fileImage = array(
   'pdf' => 'images/Adobe_PDF_icon.png',
   'jpg' => 'images/jpeg_icon.jpeg');
while(false != ($file = readdir($dir))){
         echo ("<p><a href=\"$file\"> <img src='images/folder.jpeg' /> $file</a> </p>");
         $FileParts = explode(',',$file);
         $FileExtension = strtolower($FileParts[count($FileParts) - 1]);
         echo("<p><a href=\"$file\">".(isset($fileImage[$FileExtension]) ? "<img src='".$fileImage[$FileExtension]."' />" : "<img src='unknown.gif' />")." $file</a> </p>");
Ty44ler's Avatar, Join Date: Jun 2009
Newbie Member
I just checked the output code... all the images are coming up as unknown...

Why is that?