当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form_Element_File::setMaxFileSize方法代码示例

本文整理汇总了PHP中Zend_Form_Element_File::setMaxFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_File::setMaxFileSize方法的具体用法?PHP Zend_Form_Element_File::setMaxFileSize怎么用?PHP Zend_Form_Element_File::setMaxFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form_Element_File的用法示例。


在下文中一共展示了Zend_Form_Element_File::setMaxFileSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildFileUpload

 protected function buildFileUpload()
 {
     $tenantFromIdentity = OpenSKOS_Db_Table_Tenants::fromIdentity();
     // We always need tenant for getting icon path.
     if (null !== $tenantFromIdentity) {
         $iconUpload = new Zend_Form_Element_File('icon');
         $iconUpload->setLabel('Upload a new icon:')->addValidator('Count', false, 1)->setRequired(true);
         $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor');
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['uploadPath'])) {
             $iconUpload->setDestination(APPLICATION_PATH . $editorOptions['schemeIcons']['uploadPath'] . '/' . $tenantFromIdentity->code);
         } else {
             $iconUpload->setDestination(APPLICATION_PATH . self::DEFAULT_UPLOAD_PATH . '/' . $tenantFromIdentity->code);
         }
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['allowedExtensions'])) {
             $iconUpload->addValidator('Extension', false, $editorOptions['schemeIcons']['allowedExtensions']);
         } else {
             $iconUpload->addValidator('Extension', false, 'jpg, jpeg, png, gif');
         }
         if (isset($editorOptions['schemeIcons']) && isset($editorOptions['schemeIcons']['maxSize'])) {
             $iconUpload->addValidator('Size', false, $editorOptions['schemeIcons']['maxSize']);
             $iconUpload->setMaxFileSize($editorOptions['schemeIcons']['maxSize']);
         } else {
             $iconUpload->addValidator('Size', false, 2097152);
             $iconUpload->setMaxFileSize(2097152);
         }
         $this->addElement($iconUpload, 'icon');
     }
     return $this;
 }
开发者ID:olhsha,项目名称:OpenSKOS2tempMeertens,代码行数:29,代码来源:UploadIcon.php

示例2: init

 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $registry = Zend_Registry::getInstance();
     $authedUserInfo = $registry->get('authedUserInfo');
     $uploadStatus = $registry->get("uploadStatus");
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $file = new Zend_Form_Element_File('file');
     $file->setLabel('Files:');
     $file->setRequired(true);
     $file->addValidator('Count', false, array('min' => 1, 'max' => 1));
     if ($uploadStatus['bandwidth']['remainingbytes'] > 0) {
         $maxFileSize = $uploadStatus['filesize']['maxbytes'];
     } else {
         $maxFileSize = 0;
     }
     $file->addValidator('Size', false, $maxFileSize);
     // hack for not showing 'the file exceeds the defined form size'
     $file->setMaxFileSize($maxFileSize * 2);
     /*$file->setMultiFile(1);*/
     $this->addElement($file, 'file');
     $title = $this->addElement('text', 'title', array('label' => 'Title:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 100)))));
     $short = $this->addElement('text', 'short', array('label' => 'Short description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 120)))));
     $description = $this->addElement('textarea', 'description', array('label' => 'Description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 4096)))));
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:28,代码来源:Upload.php

示例3: init

 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $signedUserInfo = $registry->get('signedUserInfo');
     $uploadStatus = $registry->get("uploadStatus");
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $file = new Zend_Form_Element_File('file');
     $file->setRequired(false);
     $file->setLabel('What do you want to share today?');
     if ($uploadStatus['bandwidth']['remainingbytes'] > 0) {
         $maxFileSize = $uploadStatus['filesize']['maxbytes'];
     } else {
         $maxFileSize = 0;
     }
     $file->addValidator('Size', false, $maxFileSize);
     $file->setMaxFileSize($maxFileSize);
     $file->setMultiFile(4);
     $file->addValidator('Count', false, array('min' => 0, 'max' => 4));
     $this->addElement($file, 'file');
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'submitupload', array('label' => 'Upload!', 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:26,代码来源:Upload.php

示例4: init

 public function init()
 {
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $file = new Zend_Form_Element_File('Image');
     $file->setLabel('Choose a picture:');
     $file->addValidator('Count', false, 1);
     $file->addValidator('Size', false, array('max' => '1MB'));
     $file->setMaxFileSize(2048 * 1024);
     $file->addValidator('Extension', false, 'jpg,png,gif');
     $file->setRequired(false);
     $file->setOptions(array('ignoreNoFile' => true));
     $this->addElement($file, 'Image');
     $this->addElement('submit', 'submit', array('label' => 'Submit!', 'class' => 'btn primary'));
     $this->addElement('submit', 'delete', array('label' => 'Delete current', 'class' => 'btn danger'));
     $this->setAttrib('class', 'form-stacked');
     $this->addElement(Ml_Model_MagicCookies::formElement());
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:20,代码来源:Picture.php

示例5: testAutoGetPostMaxSize

 public function testAutoGetPostMaxSize()
 {
     $this->element->setMaxFileSize(-1);
     $this->assertNotEquals(-1, $this->element->getMaxFileSize());
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:5,代码来源:FileTest.php


注:本文中的Zend_Form_Element_File::setMaxFileSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。