Hey dude(tte)s,
I'm trying to print the mime types of a bunch of file on disk and stuff them into a database. The database is supposed to contain the path to the file, a mime type, and some other info, but the mime_types are often missing.
I've opened a connection to my db and I can print out the name of the file and see if it exists with the following
<?
#do something
$sql = 'select id, diskfile, file_type from mantis_bug_file_table where file_type = ?';
#$data = array('text/plain');
$data = array('');
$res =& $db->query($sql, $data);
// Always check that result is not an error
if (DB::isError($res)) {
die($res->getMessage());
}
while ($row =& $res->fetchRow(DB_FETCHMODE_ASSOC)) {
echo "<p>" . $row['diskfile'] . "</p>";
$mt = MIME_Type::autodetect($row['diskfile'] );
if (PEAR::isError($mt)){
#die($mt->getMessage());
echo $mt->getMessage();
} else {
# echo "<p>" . MIME_Type::parse($mt) . "</p>";
}
}
?>
but with this code, I get a pear error Can't find file command "file".
Mime_Type depends on System_command; I think for some reason it can't run the unix command /usr/bin/file. /usr/bin is in apache's path.
Is my syntax wrong, or are there permissions to check? I'm still pretty green to php.