本文整理汇总了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;
}
示例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)))));
}
示例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');
}
示例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());
}
示例5: testAutoGetPostMaxSize
public function testAutoGetPostMaxSize()
{
$this->element->setMaxFileSize(-1);
$this->assertNotEquals(-1, $this->element->getMaxFileSize());
}