【问题标题】:zend framework upload image false extension file uploadzend框架上传图片假扩展文件上传
【发布时间】:2011-03-24 12:25:44
【问题描述】:

这是我的表单代码,当我上传时出现错误:“文件 'swing-layout-1.0.4-src.zip' 的扩展名错误”

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

}

【问题讨论】:

    标签: zend-framework file forms upload


    【解决方案1】:

    我认为应该有'zip,rar' 而不是'.zip,rar'

    【讨论】:

      猜你喜欢
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-21
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      相关资源
      最近更新 更多