# Check Upload file type (multiple)

**URL:** <https://forum.kirupa.com/t/check-upload-file-type-multiple/315707>\
**Category:** programming\
**Created:** [November 2, 2010, 2:32pm UTC](https://forum.kirupa.com/t/check-upload-file-type-multiple/315707 "2010-11-02T14:32:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shekargoud](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@shekargoud](https://forum.kirupa.com/u/shekargoud)\
**Post date:** [November 2, 2010, 2:32pm UTC](https://forum.kirupa.com/t/check-upload-file-type-multiple/315707/1 "2010-11-02T14:32:14Z")

</div>

I would like to upload multiple files(image) to folder and I am storing image names to database image and image2 like that give any idea.  
How can I check if a file extension and mime type are in an array this is the code I currently have.

This is my index code…

```php

<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input type="file" name="image2" /><br />
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input type="submit" id="submit" value="Upload" />
</form>

```

and this is my upload.php code.

```php

function is_valid_type($file)
{
    // This is an array that holds all the valid image MIME types
    $valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif","image/png");

foreach ($_FILES['image'] as $file) {

    if (!in_array($file['type'], $valid_types))
        return 1;
    return 0;
}
}

```
