extension/ezjscore/classes/ezjscserverfunctionsajaxuploader.php
static function preview( $args )
    {
        $http = eZHTTPTool::instance();
        $handler = self::getHandler( $args );
        if ( !$handler->canUpload() )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader',
                    'You are not allowed to upload a file.'
                )
            );
        }

        $file = $http->postVariable( 'UploadFile', false );
        $fileHandler = eZClusterFileHandler::instance();
        if ( $file === false
                || !$fileHandler->fileExists( $file )
                || !$fileHandler->fileFetch( $file ) )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader', 'Unable to retrieve the uploaded file.'
                )
            );
        }
        else
        {
            $tmpFile = eZSys::cacheDirectory() . '/' .
                        eZINI::instance()->variable( 'FileSettings', 'TemporaryDir' ) . '/' .
                        str_replace(
                            array( '/', '\\' ), '_',
                            $http->postVariable( 'UploadOriginalFilename' )
                        );
            eZFile::rename( $file, $tmpFile, true );
            $fileHandler->fileDelete( $file );
            $fileHandler->fileDeleteLocal( $file );
        }

        $contentObject = $handler->createObject(
            $tmpFile,
            $http->postVariable( 'UploadLocation', false ),
            $http->postVariable( 'UploadName', '' )
        );
        unlink( $tmpFile );

        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'object', $contentObject );
        return array(
            'meta_data' => $handler->serializeObject( $contentObject ),
            'html' => $tpl->fetch( 'design:ajaxuploader/preview.tpl' )
        );
    }
static function preview( $args )
    {
        $http = eZHTTPTool::instance();
        $handler = self::getHandler( $args );
        if ( !$handler->canUpload() )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader',
                    'You are not allowed to upload a file.'
                )
            );
        }

        $file = $http->postVariable( 'UploadFile', false );
        $fileHandler = eZClusterFileHandler::instance();
        if ( $file === false
                || !$fileHandler->fileExists( $file )
                || !$fileHandler->fileFetch( $file ) )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader', 'Unable to retrieve the uploaded file.'
                )
            );
        }
        else
        {
            $tmpFile = eZSys::cacheDirectory() . '/' .
                        eZINI::instance()->variable( 'FileSettings', 'TemporaryDir' ) . '/' .
                        str_replace(
                            array( '/', '\\' ), '_',
                            $http->postVariable( 'UploadOriginalFilename' )
                        );
            eZFile::rename( $file, $tmpFile, true );
            $fileHandler->fileDelete( $file );
            $fileHandler->fileDeleteLocal( $file );
        }

        $contentObject = $handler->createObject(
            $tmpFile,
            $http->postVariable( 'UploadLocation', false ),
            $http->postVariable( 'UploadName', '' )
        );
        unlink( $tmpFile );

        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'object', $contentObject );
        return array(
            'meta_data' => $handler->serializeObject( $contentObject ),
            'html' => $tpl->fetch( 'design:ajaxuploader/preview.tpl' )
        );
    }
static function preview ( $ args ) { $ http = eZHTTPTool :: instance ( ) ; $ handler = self :: getHandler ( $ args ) ; if ( ! $ handler -> canUpload ( ) ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'You are not allowed to upload a file.' ) ) ; } $ file = $ http -> postVariable ( 'UploadFile' , false ) ; $ fileHandler = eZClusterFileHandler :: instance ( ) ; if ( $ file === false || ! $ fileHandler -> fileExists ( $ file ) || ! $ fileHandler -> fileFetch ( $ file ) ) { throw new RuntimeException ( ezpI18n :: tr ( 'extension/ezjscore/ajaxuploader' , 'Unable to retrieve the uploaded file.' ) ) ; } else { $ tmpFile = eZSys :: cacheDirectory ( ) . '/' . eZINI :: instance ( ) -> variable ( 'FileSettings' , 'TemporaryDir' ) . '/' . str_replace ( array ( '/' , '\\' ) , '_' , $ http -> postVariable ( 'UploadOriginalFilename' ) ) ; eZFile :: rename ( $ file , $ tmpFile , true ) ; $ fileHandler -> fileDelete ( $ file ) ; $ fileHandler -> fileDeleteLocal ( $ file ) ; } $ contentObject = $ handler -> createObject ( $ tmpFile , $ http -> postVariable ( 'UploadLocation' , false ) , $ http -> postVariable ( 'UploadName' , '' ) ) ; unlink ( $ tmpFile ) ; $ tpl = eZTemplate :: factory ( ) ; $ tpl -> setVariable ( 'object' , $ contentObject ) ; return array ( 'meta_data' => $ handler -> serializeObject ( $ contentObject ) , 'html' => $ tpl -> fetch ( 'design:ajaxuploader/preview.tpl' ) ) ; }
Creates the object from the uploaded file and displays the preview of it

@param array $args
@return array
@throw RuntimeException if the previously uploaded file cannot be fetched
Creates the object from the uploaded file and displays the preview of it