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?
Thanks
k90tour2
0
Newbie Poster
Recommended Answers
Jump to PostIf you can, use file command through exec():
exec("file -b --mime-type $file");
Or finfo_file():
<?php $file = 'test.pdf'; $finfo = finfo_open(FILEINFO_MIME_TYPE); $result = finfo_file($finfo, $file); # echo mime-type finfo_close($finfo); ?>
Jump to PostYes 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:
- https://developer.mozilla.org/en/How_Mozilla_determines_MIME_Types
This is way I suggested you to use finfo or exec/file, both use …
All 7 Replies
cereal
1,524
Nearly a Senior Poster
Featured Poster
k90tour2
0
Newbie Poster
k90tour2
0
Newbie Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
k90tour2
0
Newbie Poster
cereal
1,524
Nearly a Senior Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.