Upload script with filter and CHMOD.. but does something worng

i have a little script it works fine WITHOUT filter but if i give the filter a extention somehow it give an error altough the file is correct… :S


if(isset($_POST['upload'])){ 
    if (!empty($_FILES['file']['name'])){ 
            $formats == array('pdf'); //* file extentie check *//
            if(in_array(strtolower(substr($_FILES['file']['name'],-3)),$formats)) { 
                echo "<p>&nbsp;&nbsp;<font class=\"error\">Dit is geen PFD (adobe acrobat) bestand...<Br>"; //* file extentie error message *//
					}else{ 
						mkdir($path . $_POST['dir'],0777);   
                copy($_FILES['file']['tmp_name'], $path . $_FILES['file']['name']); 
                unlink($_FILES['file']['tmp_name']); 
             
                echo "<p>&nbsp;&nbsp;<font class=\"error\">Bestand geupload met succes..<Br>"; 
            } 

    }else{ 

        echo "
"; 
        exit(); 

    } 
}