This is my code for a form and i am getting an error when i am uploading :"File 'swing-layout-1.0.4-src.zip' has a false extension"
<?php
class Admin_Form_Banner extends ZendX_Form_Designed {
public function init() {
$this->setEnctype(self::ENCTYPE_MULTIPART);
$this->setMethod(self::METHOD_POST);
$this->setMethod('post');
// Add an email element
$this->addElement('text', 'banner_title', array(
'label' => 'Banner Title',
'required' => true,
'filters' => array('StringTrim')
));
$this->addElement('text', 'banner_type', array(
'label' => 'Banner Type',
'required' => true,
'filters' => array('StringTrim')
));
$this->addElement('checkbox', 'is_active', array(
'label' => 'Is Active',
'required' => true,
'filters' => array('StringTrim')
));
$banner_position = new Zend_Form_Element_Select('banner_position');
$banner_position->setMultiOptions($this->getBannerPositions())->setLabel('Banner Position');
$this->addElement($banner_position, 'banner_position');
$file = new Zend_Form_Element_File('file');
$file->addValidator('Count', FALSE, 1);
开发者_如何转开发 $file->addValidator('Size', FALSE, 67633152);
$file->addValidator('Extension', false,'.zip,rar');
$file->setRequired(FALSE);
$file->setAllowEmpty(false);
$this->addElement($file, 'file_path', array('label' => 'Attacehd file'));
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => ''
));
}
public function getBannerPositions() {
$db = Zend_Db_Table::getDefaultAdapter();
$bannerPosition = $db->fetchPairs($db
->select()
->from('banner_position'), array('id', 'banner_position'));
return $bannerPosition;
}
}
I think there should be 'zip,rar'
rather than '.zip,rar'
.
精彩评论