You can check the file name to send.
"hook to the <form> onsubmit with whatever method" {
filename = theFileElement.value;
if (!/\.pdf$/i.test(filename)) {
alert("error");
return false;
}
return true;
}
Note that this only checks if the file has an extension .pdf. It does not (and cannot) check whether the file is really just a PDF or actually a nasty virus. In addition, client-side Javascript can be easily circumvented, so you must run server-side validation again.
source
share