I have created a web form with PHP.&nbsp; The webform is in online application form, that then emails our HR department.&nbsp; They want me to include an option on the form to upload a resume.&nbsp; I would like to stem off some trouble by making sure that the file they upload is one of our &quot;acceptable&quot; formats.&nbsp; (Arguments about acceptable can be tabled -- I had to fight them to accept .txt file formats)<br>

<br>I have my check working, but I have two questions about it:<br><br>1) It seems to be a bit of a clug - can I clean it up some?<br>2) What false-positives could occur?<br><br>Here is a snip:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error_reporting(0);<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // initialize a array to hold any errors we encounter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $errors = array();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check to see if a first name was entered<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$_POST[&#39;fName&#39;])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $errors[] = &quot;First Name is required&quot;;<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check to see if a last name was entered<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$_POST[&#39;lName&#39;])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $errors[] = &quot;Last Name is required&quot;;<br>&nbsp;<br>CUT SOME STUFF OUT HERE......<br><br>&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check file types against known extensions<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $whitelist = array(&quot;.rtf&quot;, &quot;.doc&quot;, &quot;.txt&quot;, &quot;.pdf&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // initialize the extension errors counter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ext_err = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // check the file extension <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ($whitelist as $item) {<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!preg_match(&quot;/$item\$/i&quot;, $_FILES[&#39;userfile&#39;][&#39;name&#39;]))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ext_err = $ext_err + 1 ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($ext_err == 4)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; $errors[] = &quot;We only allow certain file formats &quot; .$ext_err;<br>

<br>From the &quot;foreeach&quot; loop down is that part that I would think I could clean up some.. but I just can&#39;t seem to figure it out myself.<br><br>Thanks, <br>Kevin<br>