you could use the command "file -bin your_filename" and capture the output using popen
or exec.
i have found this to work well..
seee below....
function mimetype($file)
{
// execute command
$fp = popen("file -bin $file","r");
// determine mimetype to output
if(!$fp)
{
// default mimetype if no mimetype exists
$mimetype="application/octet-stream";
}
else
{
// iterate through return value to determine mimetype
while($string=fgets($fp, 1024))
{
$mimetype .= $string;
}
pclose($fp);
}
// return output
return $mimetype;
}
Php List wrote:
> Hi,
> Is it possible to get a mime type of a file?
> I need to be able to attach files, but I won't always know the mime type of what is
>being attached.
> I could look at the extension of the file for a general Idea, but I wouldn't know if
>a .jpg file is an image/jpg or image/jpeg.(progressive) and there seems to be a
>difference between the two.
>
> Thanks for any help.
> Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php