I have written a little bit of code for checking a file input for the extension and only letting through if its allowed but it doesnt seem to be working.
I call the function by using the following:
$vcFileType = check_filetype($HTTP_POST_FILES['cv']['name'],"That filetype isnt allowed punk",array('doc','docx','pdf'));
and the function is as follows:
function check_filetype($file, $problem='', $types){
$fileExt = substr($file, strrpos($file, '.') + 1);
if(in_array($fileExt, $types)){
show_error($problem);
}
return $file;
}
If someone could let me know where im going wrong, that would be grand.
Cheers,