<?php

class MFileField extends MTextField
{
    public function __construct( $name='', $value='', $label='', $size=40, $hint='' )
    {
        parent::__construct( $name, $value, $label, $size, $hint );
        $this->type = 'file';
        $this->page->addDojoRequire("dojo.io.iframe");
        $this->page->onLoad("miolo.page.fileUpload = 'yes';");
    }
    public function copyFile( $path )
    {
        if( $f=$_FILES[$this->name]['tmp_name'])
        {
            copy( $f, $path );
            return true;
        }
        else
        {
            return false;
        }
    }

    public function getTempFileName( )
    {
        return $_FILES[$this->name]['tmp_name'];
    }

    public function getFileName( )
    {
        return $_FILES[$this->name]['name'];
    }

    public function getFileType( )
    {
        return $_FILES[$this->name]['type'];
    }

    public function generateInner()
    {
        parent::generateInner();
        $hidden = new MHiddenField('__ISFILEUPLOADPOST','yes');
        $this->inner .= $hidden->generate();
    }
}

?>