Hallo Tom,
Ich will nun für ein kleines Programm nur PDF-Dokumente erlauben, mich aber ungerne auf die Dateiendung der Nutzereingabe verlassen, ebenswo wenig auf den nutzergeseteuerten $_FILES-Array. Was bleibt mir da übrig?
Solange Du noch http://de2.php.net/manual/en/function.mime-content-type.php zur Verfügung hast, kannst Du das benutzen. Die velinkte Klasse mit "fileinfo" ist aber nicht zu empfehlen!
warum? PHP ist ja anderer Ansicht.
Für den hier vorliegenden Spezialfall prüft file übrigens auf
0 string %PDF- PDF document
5 byte x \b, version %c
7 byte x \b.%c
was kein Wunder ist, denn die aktuelle Spezifikation (PDF 1.7) sagt auf Seite 92:
#--------------------------------------------------------------------------
<zitat>
3.4.1 File Header
The first line of a PDF file is a header identifying the version of the PDF
specification to which the file conforms. For a file conforming to PDF 1.7,
the header should be
%PDF−1.7
However, since any file conforming to an earlier version of PDF also conforms
to version 1.7, an application that processes PDF 1.7 can also accept files
with any of the following headers:
%PDF−1.0
%PDF−1.1
%PDF−1.2
%PDF−1.3
%PDF−1.4
%PDF−1.5
%PDF−1.6
</zitat>
#--------------------------------------------------------------------------
Freundliche Grüße
Vinzenz