I'm doing errorchecking on uploaded files. In addition to checking filetype, I'm using substr() to check whether the file suffix is correct.
if (substr($_FILES['file']['name'], -4) != ".pdf" && substr($_FILES['file']['name'], -4) != ".PDF") {
// generate error
}
But it ain't working. I can run .html files, or whatever, past it and they get through. If I switch it to
if (substr($_FILES['file']['name'], -4) == ".pdf") {
// generate error
}
and then upload a .pdf, I do get an error (as expected).
What am I doing wrong?