Forum Moderators: coopster
if(($_FILES['mapFile']['type']!="application/msword") && ($_FILES['mapFile']['type']!="application/pdf")
{
die ("$user, File must be a pdf or Word doc! ");
}
Has worked 100% for pdf about 70% for word docs.
I printed out the filetype on a doc that had failed hoping to see something different but the the file type was correct.
I attempted to upload the documents expecting an error and they both loaded fine.
Do some browsers not send a datatype with a file?
Do some browsers not send a datatype with a file?
Yes, that is possible. I just wanted to confirm this for you. If you haven't read through Handling file uploads [php.net] yet you really should. It is a must read for PHP developers. From that page ...
$_FILES['userfile']['type']The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted.
I can't use the 'file' command until the doc is already uploaded.
There isn't another way. You have to either trust what the browser says for the file type, or check it yourself after uploading it. And trusting the browser isn't a good idea.
$ file LOST.doc
LOST.doc: Microsoft Office Document
$ file 1748.pdf
1748.pdf: PDF document, version 1.3
Would there be any variations of these strings, other than the version number of the pdf?