On the contrary, checking for the extension is the only reliable way and relying on the MIME-type provided in the $_FILES array is very insecure (it can be faked by the user).
If the file has a .doc or .txt extension, but it was instead a malicious file, at least you can rest assured that it won't be executed properly (e.g. a .exe file).
I would caution you not to do a simply string check as g0dzuki suggested, as this can allow malicious files (e.g. a filename of evil_virus.txt.exe would be allowed) but instead use a function such as [man]pathinfo/man to get the extension. Alternatively, you could use some regexp:
if(preg_match('/\.(txt|doc)$/i', $filename)) {
// extension is allowed
} else {
// bad extension
}