note 32752 deleted from function.filetype by sniper
| From: | sniper@php.net | Date: | Fri, 31 Oct 2003 13:36:21 +0000 |
| Subject: | note 32752 deleted from function.filetype by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59577@lists.php.net to get a copy of this message | ||
Note Submitter: marty@excudo.net
----
For those of you wandering how to use the 'file' command in a system call (as justin [1st
post]) suggested - in order to get the mime-type - this is how to do it:
<?php
$handle = popen("/usr/bin/file -b '".addslashes($path_2_file)."'",
"r");
$filetype = fread($handle, 100);
pclose($handle);
// $filetype will now contain the mime-type and you can echo it on your screen whenever you like
;-)
?>
Note: this will probably not always yield the desired result. For examply a .doc (Microsoft _Word_
Document) will become Microsoft 'Office' Document