我如何获取文件的图标并在网站应用程序上显示它

I'm programing a downloads site on CodeIgniter 2.1.3 on Windows 8. I would like to get and show the file's icon of every file the users upload. The files can have any extension (.exe, .mpg, .rar, .pdf). How I can do that?

The only way to do this is to get all your associated file icons as images you can download them at many places e.g. here iconarchive .doc .jpg .pdf, etc and put them in a folder and then based on the file extension using PHP you display the appropriate file icon.

I have created a script to read file data in a folder, you can then get filename and get specific file extension, I was only working with pdf here so didnt care much about different extensions

function displayDocuments($path){   

 if ($handle = opendir($path))
 {

   $up = substr($path, 0, (strrpos(dirname($path."/."),"/")));
   $order = '"desc"';
   $csvarray = array(array('Type','Document','Last Modified','File Size'));
/*   echo "<table id='Docs'>";
     echo "<thead id='DocsHeaderRow'>";
   echo "<th colspan='2' align='center' data-sort='string'>File Name</th>";
   echo "<th align='center' data-sort='float'>Last Modified</th>";
   echo "<th align='center' data-sort='int' >File Size</th>";
  // echo "<a href='".$_SERVER['PHP_SELF']."?path=$up'>Up one level</a>";
   echo "</thead>";
echo "<tbody>";*/
   while (false !== ($file = readdir($handle)))
   {
     $files[] = $file;

       if ($file != "." && $file != ".." && $file != "documents.csv")
       {
           $fName  = preg_replace("/\\.[^.\\s]{3,4}$/", "", $file);
           $file   = $path.'/'.$file;
           $fileSize = filesize($file);
           //$sitename = bloginfo('template_directory');
          // $fileSizefinal = number_format($fileSize/1048576,1)."MB";

           if ($fileSize >= 1048576)
    {
        $fileSizefinal = number_format($fileSize / 1048576, 2) . ' MB';
    }
    elseif ($fileSize >= 1024)
    {
        $fileSizefinal = number_format($fileSize / 1024, 2) . ' KB';
    }

           if(is_file($file)) {
        arsort(filemtime($file));   

             /*  echo "<tr>";
               echo "<td><img src='";
               echo bloginfo('template_directory');
               echo "/images/Adobe_Acrobat_PDF.png' id='docIcon' border='0'/>";
               echo "</td>";
               echo "<td><a href='".$file."'>".$fName."</a></td>"
                        ."<td align='right'>&nbsp;".date ('Y-m-d H:i:s', filemtime($file))."</td>"
                        ."<td align='right'>&nbsp;".$fileSizefinal."</td></tr>";*/
           } elseif (is_dir($file)){
               print "<tr><td colspan='3'> -D- <a href='".$_SERVER['PHP_SELF']."?path=$file'>$fName</a></td></tr>";
           }
           $csvrowarray = array("<img src='http://10.200.200.42//wp-content/themes/socdev/images/Adobe_Acrobat_PDF.png' id='docIcon' border='0'/>","<a href='".$file."'>".$fName."</a>",date ('Y-m-d', filemtime($file)),$fileSizefinal);
           //H:i:s time on date

           array_push($csvarray,$csvrowarray);

       }
   }