private static function traverse($name, $type, $tmp_name, $error, $size, Dictionary $dict, $path)
    {
        if (is_array($name))
        {
            $keys = array_keys($name);
            foreach ($keys as $key)
            {
                $new_path = $path;
                $new_path[] = $key;
                if (
                    !array_key_exists($key, $name) ||
                    !array_key_exists($key, $type) ||
                    !array_key_exists($key, $error) ||
                    !array_key_exists($key, $tmp_name) ||
                    !array_key_exists($key, $size)
                )
                {
                    throw new FileUploadException("Missing information for file upload " . implode(".", $new_path));
                }
                self::traverse($name[$key], $type[$key], $tmp_name[$key], $error[$key], $size[$key], $dict, $new_path);
            }
        }
        else
        {

            $file = new FileUpload($path, $name, $type, $tmp_name, $error, $size);
            $path[] = $file;
            $dict->set($path, null);
            $dict->set('_files', $file->getFieldName(), $file);
        }
    }
private static function traverse($name, $type, $tmp_name, $error, $size, Dictionary $dict, $path)
    {
        if (is_array($name))
        {
            $keys = array_keys($name);
            foreach ($keys as $key)
            {
                $new_path = $path;
                $new_path[] = $key;
                if (
                    !array_key_exists($key, $name) ||
                    !array_key_exists($key, $type) ||
                    !array_key_exists($key, $error) ||
                    !array_key_exists($key, $tmp_name) ||
                    !array_key_exists($key, $size)
                )
                {
                    throw new FileUploadException("Missing information for file upload " . implode(".", $new_path));
                }
                self::traverse($name[$key], $type[$key], $tmp_name[$key], $error[$key], $size[$key], $dict, $new_path);
            }
        }
        else
        {

            $file = new FileUpload($path, $name, $type, $tmp_name, $error, $size);
            $path[] = $file;
            $dict->set($path, null);
            $dict->set('_files', $file->getFieldName(), $file);
        }
    }
private static function traverse ( $ name , $ type , $ tmp_name , $ error , $ size , Dictionary $ dict , $ path ) { if ( is_array ( $ name ) ) { $ keys = array_keys ( $ name ) ; foreach ( $ keys as $ key ) { $ new_path = $ path ; $ new_path [ ] = $ key ; if ( ! array_key_exists ( $ key , $ name ) || ! array_key_exists ( $ key , $ type ) || ! array_key_exists ( $ key , $ error ) || ! array_key_exists ( $ key , $ tmp_name ) || ! array_key_exists ( $ key , $ size ) ) { throw new FileUploadException ( "Missing information for file upload " . implode ( "." , $ new_path ) ) ; } self :: traverse ( $ name [ $ key ] , $ type [ $ key ] , $ tmp_name [ $ key ] , $ error [ $ key ] , $ size [ $ key ] , $ dict , $ new_path ) ; } } else { $ file = new FileUpload ( $ path , $ name , $ type , $ tmp_name , $ error , $ size ) ; $ path [ ] = $ file ; $ dict -> set ( $ path , null ) ; $ dict -> set ( '_files' , $ file -> getFieldName ( ) , $ file ) ; } }
Helper function to recursively traverse the uploaded files array.
@param array|string $name The name
@param array|string $type The content-type
@param array|string $tmp_name The temporary file name
@param array|int $size The file size
@param Dictionary $dict The dictionary where to store the files
@param array $path The path in the traversal
Helper function to recursively traverse the uploaded files array .