From: Shaun M. <sh...@ae...> - 2005-07-26 21:51:35
|
On 26 Jul 2005, at 16:18, Verdon Vaillancourt wrote: > > if (!function_exists('mime_content_type')) { > function mime_content_type($f) { > $f = escapeshellarg($f); > return trim( `file -bi $f` ); > } > } > $type = mime_content_type($file); > > However, I suspect this will not work on a windows server. I suspect it won't work in safe_mode either. How about using... http://pear.php.net/package/MIME_Type ...which does the grunt work for you. <?php require 'MIME/Type.php'; echo MIME_Type::autoDetect('file.mp3'); ?> It uses either the php function, or the file command if available, otherwise it raises an error. There's also http://www.phpclasses.org/browse/package/922.html which runs off file extensions and a mime.types file but that's a little dangerous. Stick with PEAR. Shaun aegis design - http://www.aegisdesign.co.uk |