Generally, it is easier to determine whether or not a file is ASCII, instead of vice-versa. If it's not, it's obviously binary. Don't use the file extension, instead use the MIME content-type:
$filetype = $_FILES['filename']['type'];
if (ereg("text", $filetype)) {
echo "ASCII File";
}
else {
echo "Binary File";
}
The assigned value of $filetype for any ASCII file will be text/sometype (where "sometype" is something like plain, or html, or any valid text file type). If $filetype does not begin with "text", then the file is then Binary.
Note that filename must be an uploaded file that has been passed from a form in the last instance.