thomas-peter
thomas-peter

Reputation: 7944

How can I return a content-type style mime type from the FileInfo package?

$finfo = new Finfo();
echo $finfo->file('image.jpg' );

As this stands, it outputs "JPEG image data, JFIF standard 1.01"

How can I modify this behaviour to output "image/jpeg"?

I would have liked to use the 'file' command but I'm not permitted to run system commands.

Upvotes: 0

Views: 77

Answers (1)

Aleks G
Aleks G

Reputation: 57316

You have to specify what info you need - FILEINFO_MIME_TYPE in your case:

$finfo = new Finfo(FILEINFO_MIME_TYPE);
echo $finfo->file('image.jpg');

Outputs:

image/jpeg

Upvotes: 2

Related Questions