Чтобы точно определить, что было загружено, вы не проверяете ни расширение файла, ни тип MIME, отправленный браузером .
В среде * nix у вас есть утилита для проверки типа MIME данного файла, обычно расположенная в файле magic.mime (/usr/share/magic.mime или что-то подобное, в зависимости от вашей настройки).
Копирование / вставка из magic.mime, чтобы вы поняли, как это работает в двух словах:
# Magic data for KMimeMagic (originally for file(1) command)
#
# Note on adding additional MIME types:
#
# [RFC2045,RFC2046] specifies that Content Types, Content Subtypes, Character
# Sets, Access Types, and conversion values for MIME mail will be assigned and
# listed by the IANA.
# http://www.iana.org/assignments/media-types/
#
# Any unregistered file type should be listed with a preceding x-, as in
# application/x-foo (RFC2045 5.1), or a x., as in application/x.foo (RFC4288
# 4.3). Any non x-prefixed type should be registered with IANA and listed at
# the above address. Any other behavior is a MIME standards violation!
#
# It is preferred that when a registered MIME type exists, that
# the registered Content-Type and Subtype be used to refer to a file of
# that type, so don't use application/x-zip when application/zip is
# registered.
#
# If an active RFC suggests that a MIME registration for a new type is in
# progress, make a note of it pointing to that RFC.
#
# The format is 4-5 columns:
# Column #1: byte number to begin checking from, ">" indicates continuation
# Column #2: type of data to match
# Column #3: contents of data to match
# Column #4: MIME type of result
# Column #5: MIME encoding of result (optional)
Я свяжу вас со ссылкой, которая поможет вам в дальнейшей реализации на PHP (буквально 2 строки кода, как только вы закончите).
Если вы не можете заставить его работать после всего этого, напишите здесь в комментариях, и я предоставлю полный код, необходимый для безопасного обнаружения того, что было загружено.
Fileinfo