Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Displaying images based on list of file types? (http://www.go4expert.com/forums/displaying-images-based-list-file-types-t17846/)

Ty44ler 3Jun2009 23:40

Displaying images based on list of file types?
 
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

<?php
$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))){
   if(!in_array($file,$ignore)){
      if(is_dir($file))
      {
         echo ("<p><a href=\"$file\"> <img src='images/folder.jpeg' /> $file</a> </p>");
      }else{
         $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 4Jun2009 00:54

Re: Displaying images based on list of file types?
 
I just checked the output code... all the images are coming up as unknown...

Why is that?


All times are GMT +5.5. The time now is 17:42.