I am calling a list of files from a folder and I'm trying to display a little icon of the file type next to it in the list. Also I'm calling sub-folder names and trying to display an image of a folder next to that.
What is going wrong:
I can get one file type to show up which is the first adobe pdf icon. no others images next to the file types show up and when the file name has a . in the middle of it, the image fails to show as well. Also, folders are listed but not being detected and the correct image shown...
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: Select all
<?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>");
}
}
}
?>