PHP/MySQL PDF upload
<p>I'm using the code below to add/edit pdf's yet it doesn't seem to be working at all. Any ideas/help greatly appreciated. S</p>

<pre><code>if (is_uploaded_file($_FILES['pdfFile']['tmp_name'])) {
        $format = strtolower(substr(strrchr($_FILES['pdfFile']['name'],"."),1));            
        $str = strtolower(trim($_FILES['pdfFile']['name']));
        $str = preg_replace('/[^a-z0-9-]/', '-', $str);
        $str = preg_replace('/-+/', "-", $str);
        $pdfFileName=$str.'.'.$format;
        $pdfUploadFile=$pdfFileDir.$pdfFileName;
        $format!='pdf' ? $error='Invalid format uploaded for PDF File!&lt;br /&gt;Please only upload files with the ".pdf" extension.' : NULL;
        if (!$error &amp;&amp; move_uploaded_file($_FILES['pdfFile']['tmp_name'], $pdfUploadFile)){ 
            if($_POST['docFilename'] &amp;&amp; file_exists($pdfFileDir.'/'.$_POST['docFilename'])) {unlink($pdfFileDir.'/'.$_POST['docFilename']);}
            $_POST['docFilename']=$pdfFileName;                
            mysql_query("INSERT INTO table(docFilename, assoc_cat, assoc_object) VALUES('".$_POST['docFilename']."', '".$_POST['categoryID']."', '".$_POST['id']."')"); 
        } else {
            file_exists($pdfUploadFile) ? unlink($pdfUploadFile) : NULL;
            !$error ? $error='The chosen PDF file failed to upload correctly.&lt;br /&gt;Please try again, or attempt to upload an alternative PDF.' : NULL;
        }
    }
</code></pre>
