# Upload script, check mime type

**URL:** <https://forum.kirupa.com/t/upload-script-check-mime-type/205637>\
**Category:** Uncategorized\
**Created:** [October 31, 2006, 2:40pm UTC](https://forum.kirupa.com/t/upload-script-check-mime-type/205637 "2006-10-31T14:40:01Z")\
**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:** [October 31, 2006, 2:40pm UTC](https://forum.kirupa.com/t/upload-script-check-mime-type/205637/1 "2006-10-31T14:40:01Z")

</div>

Hi guys

Im trying to make this uploadscript but cant get it to work fully

I want to upload txt,doc or pdf files and Im checking if it has the proper extension.

I also want to check the mimetype but then the script wont work, what am I doing wrong?

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

```
