static function upload( $args )
    {
        try
        {
            $handler = self::getHandler( $args );
            $fileInfo = $handler->getFileinfo();
            $mimeData = $fileInfo['mime'];
            $file = $fileInfo['file'];
            $class = $handler->getContentClass( $mimeData );

            if ( $file->store( false, $mimeData['suffix'] ) === false )
            {
                throw new RuntimeException(
                    ezpI18n::tr(
                        'extension/ezjscore/ajaxuploader',
                        'Unable to store the uploaded file.'
                    )
                );
            }
            else
            {
                $fileHandler = eZClusterFileHandler::instance();
                $fileHandler->fileStore( $file->attribute( 'filename' ), 'tmp', true, $file->attribute( 'mime_type' ) );
            }

            $start = $handler->getDefaultParentNodeId( $class );
            $defaultParentNode = eZContentObjectTreeNode::fetch( $start );
            if ( !$defaultParentNode instanceof eZContentObjectTreeNode )
            {
                throw new RuntimeException(
                    ezpI18n::tr(
                        "extension/ezjscore/ajaxuploader",
                        "The default parent location for uploads cannot be retrieved! Check user permissions and correctness of settings."
                    )
                );
            }
        }
        catch ( Exception $e )
        {
            // manually catch exception to force json encode
            // because most browsers cannot upload
            // wit a json HTTP Accept header...
            // see JavaScript code in eZAjaxUploader::delegateWindowEvents();
            return json_encode(
                array(
                    'error_text' => $e->getMessage(),
                    'content' => ''
                )
            );
        }

        $browseItems = self::getBrowseItems( $defaultParentNode->attribute( 'parent' ), $class );

        $http = eZHTTPTool::instance();
        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'file', $file );
        $tpl->setVariable( 'name', $http->postVariable( 'UploadName', $file->attribute( 'original_filename' ) ) );
        $tpl->setVariable( 'mime_data', $mimeData );
        $tpl->setVariable( 'class', $class );
        $tpl->setVariable( 'browse_start', $defaultParentNode->attribute( 'parent' ) );
        $tpl->setVariable( 'default_parent_node', $defaultParentNode );
        $tpl->setVariable( 'browse', $browseItems );
        // json_encode and url encode the HTML to be able to get it in the
        // JavaScript code. see eZAjaxUploader::delegateWindowEvents()
        return json_encode(
            array(
                'meta_data' => false,
                'html' => rawurlencode(
                    $tpl->fetch( 'design:ajaxuploader/location.tpl' )
                )
            )
        );
    }