2011-03-24 132 views
0

這是我的表單代碼,我上傳時出現錯誤:「文件'swing-layout-1.0.4-src.zip'有一個虛假擴展名」zend框架上傳圖片虛假擴展名文件上傳

<?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; 
    } 

} 

回答

1

我認爲應該有'zip,rar'而不是'.zip,rar'