开发者

check if a files mime-type matches it's extension in php

开发者 https://www.devze.com 2023-04-04 00:40 出处:网络
Is there any way to check that a file开发者_如何学Pythons mime-type matches it\'s extension in php ?

Is there any way to check that a file开发者_如何学Pythons mime-type matches it's extension in php ?

Thanks, Adam


See here: http://www.php.net/manual/en/function.finfo-file.php. This function allows you to detect the file's mime-type.


If you have a list of known mime types with corresponding extensions, using the mime_content_type function and looking up the extension in an array is simple. There are problems, however; a comprehensive list would be large and likely become outdated fairly quickly, and sniffing mime types is generally considered a difficult problem with inaccurate solutions.

0

精彩评论

暂无评论...
验证码 换一张
取 消