Question

I have written this code:

$filename = "some/path/where/the/file/can/be/found.some_extension";
$buffer = file_get_contents($filename);
$finfo = new finfo(FILEINFO_MIME_TYPE);
var_dump($finfo->buffer($buffer));
finfo_close($finfo);

Possible outputs were of:

"image/jpeg", "image/png", "image/gif", "image/x-ms-bmp"

I would like to know, what are the possible outputs of $finfo->buffer($buffer), if the file is a png, gif, bmp, or jpg?

I have seen here a returnMIMEType function, which, for instance will not detect "image/x-ms-bmp" to be a bmp.

Était-ce utile?

La solution

We can view the possible MIME types of file extensions by searching for the file extension at the link provided by Pitchinnate. For instance BMP MIME types can be found at: filext.com/file-extension/BMP

Autres conseils

In this thread, you can find some useful suggestions and functions for your situation.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top