This function helps you get over PHP's inconsistencies regarding the data located in the $_FILES superglobal.

/* This gives you the following format (whether the requested key contains multiple files or not) :

    array(
        0: array(
            'name' => ...,
            'type' => ...,
            'tmp_name' => ...,
            'error' => ...,
            'size' => ...
        ),
        1: ...
    )
*/

function getStandardizedFiles($key)
{
    $files = array();

    if (array_key_exists($key, $_FILES)) {
        foreach ($_FILES[$key] as $property => $data) {
            if (! is_array($data)) {
                $data = array($data);
            }

            foreach ($data as $index => $value) {
                if (! array_key_exists($index, $files)) {
                    $files[$index] = array();
                }

                $files[$index][$property] = $value;
            }
        }
    }

    return $files;
}