Why the following upload if condition does not work?

Posted by Ole Media on Stack Overflow See other posts from Stack Overflow or by Ole Media
Published on 2010-03-23T22:02:06Z Indexed on 2010/03/23 22:13 UTC
Read the original article Hit count: 292

Filed under:
|

So I have an upload script, and I want to check the file type that is being uploaded. I only want pdf, doc, docx and text files

So I have:

$goodExtensions = array('.doc','.docx','.txt','.pdf', '.PDF');
$name = $_FILES['uploadFile']['name'];
$extension = substr($name, strpos($name,'.'), strlen($name)-1);


 if(!in_array($extension,$goodExtensions) || (($_FILES['uploadFile']['type'] != "applicatioin/msword") || ($_FILES['uploadFile']['type'] != "application/pdf"))){
     $error['uploadFile'] = "File not allowed. Only .doc, .docx, .txt and pdf";
 }

Why I'm getting the error when testing and including correct documents?

© Stack Overflow or respective owner

Related posts about php

Related posts about php5