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

If 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);
?>

finfo_file(): http://www.php.net/manual/en/function.finfo-file.php

bye :)

Ah, I'm only PHP 5.2 and finfo_file() is for > 5.3, according to the link that you kindly posted.
Thanks for the post cereal

My wife's Macbook Pro doesn't have a problem uploading pdfs and the $_FILES array [type] shows these as pdfs whereas my PC shows them as ldt, and won't upload.

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:

- https://developer.mozilla.org/en/How_Mozilla_determines_MIME_Types

This is way I suggested you to use finfo or exec/file, both use magic file which is used in *nix box to determine file mime-types:

- http://en.wikipedia.org/wiki/File_(command)

You may want to wait for someone else solution. Bye :)

This is way I suggested...

My bad English! Among other mistakes I meant "why" not "way".. I'm sorry this is not my first language :D

Ah ha! The problem doesn't occur with Safari or IE8. It's a Firefox thing (again).
Thanks for all your help

You're welcome! :)

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.