fileReference upload filetype check

Hi

When uploading with fileRefernce flash sends all files as application/octet-stream

I want to allow .txt, .pdf and. doc so when I check the mime type in php the upload fails, my script works in a regular html form but fails from flash.

<?php
$fil = $_FILES['Filedata']['name'];
if (preg_match("/\.(?:txt|doc|pdf)$/i", $fil)){ 
  $mime = $_FILES['Filedata']['type']; 
  if($mime == "application/msword" || $mime == "text/plain" || $mime == "application/pdf") { 
 move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_FILES['Filedata']['name']);
  }
} 
?>

Anybody know any fix for this?
I saw a code on macromedia that checks imagetypes with [COLOR=#0000bb]exif_imagetype [/COLOR]but I want to check for other filetypes

 $type = exif_imagetype("./temporary/".$_FILES['Filedata']['name']);
  if ($type == 1 || $type == 2 || $type == 3) {
    rename("./temporary/".$_FILES['Filedata']['name'], "./images/".$_FILES['Filedata']['name']);
  } else {
    unlink("./temporary/".$_FILES['Filedata']['name']);
  }