steviez Posted September 2, 2008 Share Posted September 2, 2008 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 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 More sharing options...
rarebit Posted September 2, 2008 Share Posted September 2, 2008 function type($mime) { $icons = array ( 'default' => 'file.gif', ... ); return $icons[$mime]; } mime, not extension... Link to comment https://forums.phpfreaks.com/topic/122436-help-with-simple-mime-function/#findComment-632247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.