# fileReference upload filetype check

**URL:** <https://forum.kirupa.com/t/filereference-upload-filetype-check/208066>\
**Category:** programming\
**Created:** [November 24, 2006, 3:57pm UTC](https://forum.kirupa.com/t/filereference-upload-filetype-check/208066 "2006-11-24T15:57:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rille31](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@rille31](https://forum.kirupa.com/u/rille31)\
**Post date:** [November 24, 2006, 3:57pm UTC](https://forum.kirupa.com/t/filereference-upload-filetype-check/208066/1 "2006-11-24T15:57:47Z")

</div>

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
<?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

```php
 $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']);
  }

```
