For file extensions:
$fileArray = array("jpeg","gif","txt");
$fileName = explode(".",$_FILES["myUpload"]["name"]);
if (in_array(end($fileName),$fileArray)) {echo "Success!";}
else {echo "Incorrect file type!";}
The best method IMHO though, is comparing the file's MIME type instead.
Because some jerk won't be able to easily upload any impersonations. (Assuming you're making a public uploader.) 😉
$fileArray = array("image/jpeg","image/gif","text/plain");
if (in_array($_FILES["myUpload"]["type"],$fileArray)) {echo "Success!";}
else {echo "Incorrect file type!";}
Here's a large list of file types + their MIMEs. 😃
http://www.yolinux.com/TUTORIALS/LinuxTutorialMimeTypesAndApplications.html