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


PHP Zend_Form_Element_File::getFileName方法代码示例

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


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

示例1: init

 public function init()
 {
     $user = Zend_Auth::getInstance()->getIdentity();
     $email = new Zend_Form_Element_Text('email');
     $email->setLabel('Email')->setRequired(true)->addValidator('EmailAddress')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->addErrorMessage('Email address not valid');
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setAttrib('autocomplete', 'off')->setRequired(true);
     $name = new Zend_Form_Element_Text('first_name');
     $name->setLabel('First name')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setRequired(true);
     $lastname = new Zend_Form_Element_Text('last_name');
     $lastname->setLabel('Last name')->setAttrib("class", "form-control")->setAttrib("style", "width:200px")->setRequired(true);
     $role_name = new Zend_Form_Element_Select('role_id');
     $role_name->setLabel('Account type')->setRequired(true)->setRegisterInArrayValidator(false);
     $role_name->setAttrib("class", "select2")->setAttrib("style", "width:200px");
     $roles_table = new Admin_Model_Roles();
     foreach ($roles_table->getAll() as $v) {
         $role_name->addMultiOption($v->id, $v->name);
     }
     $img = new Zend_Form_Element_File('image');
     $img->setDestination(WEB_PATH . Zend_Registry::get('upload_profile_img_path'));
     $img->addValidator('Count', false, 1);
     $img->addValidator('Extension', false, 'jpeg,jpg,png,gif');
     if ($img->getFileName()) {
         $new_name = md5(rand(1000, 10000) . time() . $img->getFileName()) . "." . preg_replace('/^.*\\.([^.]+)$/D', '$1', $img->getFileName());
         $img->addFilter('Rename', $new_name);
     }
     $img->setLabel('Image');
     $is_active = new Zend_Form_Element_Checkbox("is_active");
     $is_active->setLabel('Active')->setAttrib("class", "icheckbox_square");
     $cancel = new Zend_Form_Element_Button('cancel');
     $cancel->setLabel('Cancel');
     $cancel->setAttrib('class', 'btn btn-gold')->setAttrib('style', 'color:black');
     $cancel->setAttrib("onClick", "window.location = window.location.origin+'/admin/admin-users/'");
     $submit = new Zend_Form_Element_Submit('save');
     $submit->setAttrib('class', 'btn btn-primary');
     $submit->setLabel('Confirm');
     $this->setAction('')->setMethod('post')->addElement($email)->addElement($password)->addElement($name)->addElement($lastname)->addElement($role_name)->addElement($img)->addElement($is_active)->addElement($cancel)->addElement($submit);
 }
开发者ID:zelimirus,项目名称:yard,代码行数:38,代码来源:AdminUser.php

示例2: saveSession

 /**
  * Remember file path into session
  *
  */
 private function saveSession()
 {
     $_SESSION[$this->getIdentifier()][self::SESSION_FILE_NAME] = parent::getFileName();
     $_SESSION[$this->getIdentifier()][self::SESSION_ORIGINAL_FILE_NAME] = $this->_originalFile;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:9,代码来源:Uploadify.php

示例3: _addFileRenameFilter

 /**
  * Add filter to rename uploaded files for themes.
  *
  * @param Zend_Form_Element_File $element
  */
 private function _addFileRenameFilter($element)
 {
     $elementName = $element->getName();
     $fileName = $element->getFileName(null, false);
     $uploadedFileName = Theme::getUploadedFileName($this->getThemeName(), $elementName, $fileName);
     $uploadedFilePath = $element->getDestination() . '/' . $uploadedFileName;
     $element->addFilter('Rename', array('target' => $uploadedFilePath, 'overwrite' => true));
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:13,代码来源:ThemeConfiguration.php

示例4: testEmptyFileName

 public function testEmptyFileName()
 {
     $this->element->setTransferAdapter(new Zend_Form_Element_FileTest_MockAdapter());
     $this->element->setDestination(dirname(__FILE__));
     $this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo.jpg', $this->element->getFileName());
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:6,代码来源:FileTest.php

示例5: replaceItem

 /**
  * Replace item
  *
  * @param string $key
  * @param Zend_Form_Element_File $file
  * @return void
  * @throws InvalidArgumentException
  */
 public function replaceItem($key, \Zend_Form_Element_File $file)
 {
     $oldMime = current(explode(';', $this->storage->getMimeType($key)));
     $newMime = current(explode(';', $file->getMimeType()));
     if ($oldMime != $newMime && !(in_array($oldMime, self::$equivalentMimeTypes) && in_array($newMime, self::$equivalentMimeTypes))) {
         throw new \InvalidArgumentException(sprintf('You can only replace a file with a file of the same type.  The original file is of type "%s", and the file you uploaded was of type "%s".', $oldMime, $newMime));
     }
     $this->storage->storeItem($key, file_get_contents($file->getFileName()));
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:17,代码来源:Template.php

示例6: _processFileElement

 /**
  * Store and/or delete a file for a file element.
  *
  * @uses _deleteOldFile()
  * @param Zend_Form_Element_File $element
  */
 private function _processFileElement(Zend_Form_Element_File $element)
 {
     $elementName = $element->getName();
     // set the theme option for the uploaded file to the file name
     if ($element->getIgnore()) {
         // set the form value to the old theme option
         $this->_formValues[$elementName] = $this->_themeOptions[$elementName];
     } else {
         $path = $element->getFileName();
         if (empty($path)) {
             // Make sure null-like values are actually null when saved.
             $newFile = null;
         } else {
             $storage = Zend_Registry::get('storage');
             $newFile = basename($path);
             $storagePath = $storage->getPathByType($newFile, self::THEME_UPLOAD_TYPE);
             $storage->store($path, $storagePath);
         }
         $this->_formValues[$elementName] = $newFile;
         $this->_deleteOldFile($element);
     }
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:28,代码来源:ThemeConfiguration.php

示例7: saveUploadFile

 /**
  * @param Zend_Form_Element_File $element
  * @param $item mixed
  * @return mixed
  * @throws Exception
  *
  */
 public function saveUploadFile(Zend_Form_Element_File $element, $item)
 {
     $uploadPath = $element->getAttrib('data-upload') . '/' . $item->getId();
     if (!file_exists(APPLICATION_ROOT . $uploadPath)) {
         mkdir(APPLICATION_ROOT . $uploadPath, 0755, true);
     }
     //$element->setDestination(APPLICATION_ROOT.$uploadPath);
     $fileName = $element->getFileName(null, false);
     $path = APPLICATION_ROOT . $uploadPath . '/' . $fileName;
     $path = iconv('utf-8', 'cp1251', $path);
     try {
         $element->addFilter('Rename', array('target' => $path, 'overwrite' => true));
         $element->receive();
         $item->setOptions(array($element->getAttrib('data-input') => $uploadPath . '/' . $fileName));
         $this->getModelMapper()->save($item);
     } catch (Zend_File_Transfer_Exception $e) {
         throw new Exception('Bad image data: ' . $e->getMessage());
     }
     return $item;
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:27,代码来源:BaseController.php


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