Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top