# Upload security check

**URL:** <https://forum.kirupa.com/t/upload-security-check/208159>\
**Category:** Uncategorized\
**Created:** [November 25, 2006, 6:19pm UTC](https://forum.kirupa.com/t/upload-security-check/208159 "2006-11-25T18:19:04Z")\
**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 25, 2006, 6:19pm UTC](https://forum.kirupa.com/t/upload-security-check/208159/1 "2006-11-25T18:19:04Z")

</div>

Im using te fileReference class to upload documents, the problem I have is that flash doesnt send the mime type and I want to validate that the mime type is correct for security reasons.

Anybody knows a fix to this?

The code works in a regular html form but not with the fileReference class

```php
<?php
if (!empty($_FILES['Filedata']['name'])){ 
$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") { 
$timeStamp = time();
 $uploadDir = "files/";
 $uploadFile = $uploadDir ."$timeStamp-". $_FILES['Filedata']['name'];
 move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile);
  }
 } 
}
?>

```
