本文整理匯總了PHP中Zend_Form_Element_File::getAttrib方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Form_Element_File::getAttrib方法的具體用法?PHP Zend_Form_Element_File::getAttrib怎麽用?PHP Zend_Form_Element_File::getAttrib使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Form_Element_File
的用法示例。
在下文中一共展示了Zend_Form_Element_File::getAttrib方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}