Fileinfo does not use the file extension to determine that type of mime type, but ( quoting ):
The functions in this module try to guess the type of content and file encoding in search of a specific magic byte sequence at certain positions in the file.
The idea is that the file name and its extension are provided by users (especially in cases such as yours, where files are downloaded by users) and, as such, are less โof courseโ than the contents of the file itself.
Maybe the solution may be to not check the whole mime type returned by the info file, but to use only its first part - at least in some cases?
For example, perhaps you could accept all the mimetype that are in the text/* and image/* families and discard all that look like application/* , except for application/pdf ?
(Just an example - but you see the point)
source share