Hi. I've three websites on a VPS Server running Apache 2. Each website has been successfully uploading files until now. None of them can upload a pdf file but has no problem with other file types that I allow, such as jpeg.
If I examine the $_FILES array, when uploading a jpg, the [type] is shown as 'image/jpeg' which is permitted. When I upload a pdf, the [type] is revealed as 'application/ltd' and fails to upload. I'm expecting 'application/pdf' as the [type].
Does anyone know what might be going on here?
Jump to Post
If you can, use file command through exec():
exec("file -b --mime-type $file");
<?php $file = 'test.pdf'; $finfo = finfo_open(FILEINFO_MIME_TYPE); $result = finfo_file($finfo, $file); # echo mime-type finfo_close($finfo); ?>
Jump to Post
Yes I know, this mainly depends on how the browser determines the mime-type, for example Firefox use different methods to determine mime-types, on MacOS it uses type and creator code:
This is way I suggested you to use finfo or exec/file, both use magic …
All 7 RepliesReply to this topic
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.