note 32752 added to function.filetype
| From: | marty at excudo dot net | Date: | Thu, 05 Jun 2003 23:13:09 +0000 |
| Subject: | note 32752 added to function.filetype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49820@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.filetype.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32752
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32752&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32752&report=yes