class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
$files = array(); foreach ($_FILES['my_field'] as $k => $l) { foreach ($l as $i => $v) { if (!array_key_exists($i, $files)) $files[$i] = array(); $files[$i][$k] = $v; } }
Then you can use $files rather than $_FILES in your code. Note that you can trim out all non-uploaded images in the code above.