Jump to content

Help with simple mime function


steviez

Recommended Posts

Hi,

 

I am trying to make a mime function thet wil return the correct file icon for the file, i am not 100% with php and as you can guess i cant get my function to work :D

 

Here is what i have so far:

 

<?php
function mimeIcon($params, &$smarty)
{
   $q = @mysql_query("SELECT * FROM uploads WHERE id = '".$params['fileID']."' AND owner = '".clean($_SESSION['username'])."'");
   $file = @mysql_fetch_array($q);
   $mime = $row['file_type'];
   
   function type($mime)
   {
    $icons = array
    (
'default'   => 'file.gif',
// images
'jpg'	=> 'images.gif',
'jpeg'	=> 'images.gif',
'png'	=> 'png.gif',
'gif'	=> 'gif.gif',
// media
'avi'	=> 'video.gif',
'wmv'	=> 'video.gif',
'mpeg'	=> 'video2.gif',
'mpg'	=> 'video2.gif',
'mov'	=> 'quicktime.gif',
'mp3'	=> 'mp3.gif',
// Archives
'application/x-zip-compressed'	=> 'zip.gif',
'application/force-download'	=> 'zip.gif',
'application/x-rar'	=> 'zip.gif',
// documents
'pdf'	=> 'acrobat.gif',
'ppt'	=> 'powerpoint.gif',
'txt'	=> 'text.gif',
'doc'	=> 'word.gif',
'xls'	=> 'excel.gif',

    );
return $icons[$extension];
}

}
?>

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/122436-help-with-simple-mime-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.