I have a script which lets the users select multiple images while holding CTRL and then upload them to the server. I need to limit the number of selected images to 10, so when the user submits the form, he will get an error if there are more than 10 images.

How would I do this? 

P.S: I have a foreach loop that looks like this:

```
foreach ($_FILES['file']['tmp_name'] as $key => $tmp_name)

```

A PHP solution would be welcome. Since I do not trust javascript and jquery on this. 

**EDIT:**

This is my script: <http://pastebin.com/76NiNB6D>