upload – When uploading wrong extension file in PHP it does not show the error message defined

I have a form to send a file and in the document that receives it I have this piece of code. The file must be .pdf, and if it is not, then it should show the message that it is incorrect. But it takes me directly to the form again. Yes, the file does not upload.

The code uploads the file with the name novas.pdf but check if that name already exists and if so, rename the existing one novas_anteriores.pdf and then upload novas.pdf. It works correctly except in the case that it is not .pdf, that does not show the message.

$ targetfolder = "../Subidas/";
$ targetfolder = $ targetfolder. basename ($ _FILES['file']['name']    );
$ ok = 1;
$ file_type = $ _FILES['file']['type'];

if ($ file_type! == "application / pdf") {
  echo "ATTENTION: Only PDF files are allowed.
";   exit; } else {   if (file_exists ('../Subidas/novas.pdf')) {     rename ("../Subidas/novas.pdf", "../Subidas/novas_anteriores.pdf");   }   if ($ _FILES['file']["error"] > 0) {     echo "Error:" $ _FILES['file']['error'] . "
";   } else {     move_uploaded_file ($ _FILES['file']['tmp_name'], "../ Uploads / novas.pdf");     echo "Arquivo Uploaded Correctly";   } }