How to check if uploaded file is .pdf not .jpeg?

I like to use the following:

First I initiate an array of supported mime types:

$supportedTypes = array( 'application/pdf' );

Next I get my actual uploaded file type:

$fileType = $_FILES['type'][0]

Then I use wp_check_filetype() to get the extension and mimetype: $fileArray = wp_check_filetype( basename( $_FILES['name'][0] ) );

Finally I run a conditional to make sure that the uploaded mimetype is in my supported array:

if( in_array( $fileArray['type'], $supportedTypes ) ) {

IF the conditional is true you can proceed with your upload, otherwise the file won’t upload and you can bail out.