문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top