how to add jpg,png etc ???
{
public function __construct()
{
parent::__construct( 'photoverifiUpload' );
$this->setAjax( FALSE );
$this->setAction( OW::getRouter()->urlForRoute('photoverifi.upload') );
$this->setEnctype( Form::ENCTYPE_MULTYPART_FORMDATA );
$file = new FileField( 'photo' );
$file->setRequired();
$file->addValidator( new JpegValidator() );
$file->setLabel( OW::getLanguage()->text('photoverifi', 'file_label') );
$this->addElement( $file );
$submit = new Submit( 'send' );
$submit->setValue( OW::getLanguage()->text('photoverifi', 'submit_btn_caption') );
$this->addElement( $submit );
}
public function isValid( $data = NULL )
{
return ( !empty($_FILES['photo']) && $_FILES['photo']['error'] === 0 && $_FILES['photo']['type'] == 'image/jpeg' );
}
}
class JpegValidator extends OW_Validator
{
public function isValid( $value )
{
return preg_match( '/jpg$/', $value );
}
public function getJsValidator()
{
return '{
validate : function( value )
{
if ( !value.match("jpg$") )
{
throw OW.getLanguageText("photoverifi", "upload_type_error");
}
}
}';
}
}