本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::getMessages方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::getMessages怎么用?PHP Zend_File_Transfer_Adapter_Http::getMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::getMessages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _transferFile
/**
* Use the Zend_File_Transfer adapter to upload the file.
*
* @internal The resulting filename is retrieved via the adapter's
* getFileName() method.
*
* @param array $fileInfo
* @param string $originalFilename
* @return string Path to the file in Omeka.
*/
protected function _transferFile($fileInfo, $originalFilename)
{
// Upload a single file at a time.
if (!$this->_adapter->receive($fileInfo['form_index'])) {
throw new Omeka_File_Ingest_InvalidException(join("\n\n", $this->_adapter->getMessages()));
}
// Return the path to the file as it is listed in Omeka.
return $this->_adapter->getFileName($fileInfo['form_index']);
}
示例2: upload
public function upload($params = array())
{
if (!is_dir($params['destination_folder'])) {
mkdir($params['destination_folder'], 0777, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($params['destination_folder']);
$adapter->setValidators($params['validators']);
if ($adapter->getValidator('ImageSize')) {
$adapter->getValidator('ImageSize')->setMessages(array('fileImageSizeWidthTooBig' => $this->_('Image too large, %spx maximum allowed.', '%maxwidth%'), 'fileImageSizeWidthTooSmall' => $this->_('Image not large enough, %spx minimum allowed.', '%minwidth%'), 'fileImageSizeHeightTooBig' => $this->_('Image too high, %spx maximum allowed.', '%maxheight%'), 'fileImageSizeHeightTooSmall' => $this->_('Image not high enough, %spx minimum allowed.', '%minheight%'), 'fileImageSizeNotDetected' => $this->_("The image size '%s' could not be detected.", '%value%'), 'fileImageSizeNotReadable' => $this->_("The image '%s' does not exist", '%value%')));
}
if ($adapter->getValidator('Size')) {
$adapter->getValidator('Size')->setMessages(array('fileSizeTooBig' => $this->_("Image too large, '%s' allowed.", '%max%'), 'fileSizeTooSmall' => $this->_("Image not large enough, '%s' allowed.", '%min%'), 'fileSizeNotFound' => $this->_("The image '%s' does not exist", '%value%')));
}
if ($adapter->getValidator('Extension')) {
$adapter->getValidator('Extension')->setMessages(array('fileExtensionFalse' => $this->_("Extension not allowed, '%s' only", '%extension%'), 'fileExtensionNotFound' => $this->_("The file '%s' does not exist", '%value%')));
}
$files = $adapter->getFileInfo();
$return_file = '';
foreach ($files as $file => $info) {
//Créé l'image sur le serveur
if (!$adapter->isUploaded($file)) {
throw new Exception($this->_('An error occurred during process. Please try again later.'));
} else {
if (!$adapter->isValid($file)) {
if (count($adapter->getMessages()) == 1) {
$erreur_message = $this->_('Error : <br/>');
} else {
$erreur_message = $this->_('Errors : <br/>');
}
foreach ($adapter->getMessages() as $message) {
$erreur_message .= '- ' . $message . '<br/>';
}
throw new Exception($erreur_message);
} else {
$new_name = uniqid("file_");
if (isset($params['uniq']) and $params['uniq'] == 1) {
if (isset($params['desired_name'])) {
$new_name = $params['desired_name'];
} else {
$format = pathinfo($info["name"], PATHINFO_EXTENSION);
if (!in_array($format, array("png", "jpg", "jpeg", "gif"))) {
$format = "jpg";
}
$new_name = $params['uniq_prefix'] . uniqid() . ".{$format}";
}
$new_pathname = $params['destination_folder'] . '/' . $new_name;
$adapter->addFilter(new Zend_Filter_File_Rename(array('target' => $new_pathname, 'overwrite' => true)));
}
$adapter->receive($file);
$return_file = $new_name;
}
}
}
return $return_file;
}
示例3: uploadAction
public function uploadAction()
{
if (!empty($_FILES)) {
try {
$path = '/var/apps/iphone/';
$base_path = Core_Model_Directory::getBasePathTo($path);
$filename = uniqid() . '.pem';
if (!is_dir($base_path)) {
mkdir($base_path, 0775, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($base_path);
$adapter->setValidators(array('Extension' => array('pem', 'case' => false)));
$adapter->getValidator('Extension')->setMessages(array('fileExtensionFalse' => $this->_("Extension not allowed, \\'%s\\' only", '%extension%')));
$files = $adapter->getFileInfo();
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
throw new Exception($this->_('An error occurred during process. Please try again later.'));
} else {
if (!$adapter->isValid($file)) {
if (count($adapter->getMessages()) == 1) {
$erreur_message = $this->_('Error : <br/>');
} else {
$erreur_message = $this->_('Errors : <br/>');
}
foreach ($adapter->getMessages() as $message) {
$erreur_message .= '- ' . $message . '<br/>';
}
throw new Exception($erreur_message);
} else {
$adapter->addFilter(new Zend_Filter_File_Rename(array('target' => $base_path . $filename, 'overwrite' => true)));
$adapter->receive($file);
}
}
}
$certificat = new Push_Model_Certificat();
$certificat->find('ios', 'type');
if (!$certificat->getId()) {
$certificat->setType('ios');
}
$certificat->setPath($path . $filename)->save();
$datas = array('success' => 1, 'files' => 'eeeee', 'message_success' => $this->_('Infos successfully saved'), 'message_button' => 0, 'message_timeout' => 2);
} catch (Exception $e) {
$datas = array('error' => 1, 'message' => $e->getMessage());
}
$this->getLayout()->setHtml(Zend_Json::encode($datas));
}
}
示例4: updateProfileAction
/**
* Update profile Employee
* @return type
*/
public function updateProfileAction()
{
$this->view->headTitle('Update Profile');
$form = new Employee_Form_UpdateProfile();
$id = (int) $this->getParam('id', '');
if (!$id) {
$this->_helper->redirector('list-profile');
}
$employeeMapper = new Employee_Model_EmployeeMapper();
$result = $employeeMapper->findId($id);
if (!$result) {
$this->view->message = "Nhan vien khong ton tai";
return;
}
$this->view->form = $form;
//set up URL image
$adapter = new Zend_File_Transfer_Adapter_Http();
$uploadPath = APPLICATION_PATH . '/../public/images/avatar';
$adapter->setDestination($uploadPath);
$adapter->addFilter('Rename', $result->getEmployeeId() . '.jpg');
$this->view->fileName = $result->getEmployeeId() . '.jpg';
if (!$adapter->receive()) {
$messages = $adapter->getMessages();
}
$avatar = $adapter->getFileName();
$this->_processShowForm($form, $result);
if ($this->_processUpdateFormProfile($form)) {
echo "Update success";
$this->view->message = "Update success";
$params = array('id' => $id);
$this->_helper->redirector("show-profile", 'profile', 'employee', $params);
}
}
示例5: handleFileTransfer
/**
* handleFileTransfer
* @author Thomas Schedler <tsh@massiveart.com>
*/
private function handleFileTransfer()
{
$this->objUpload = new Zend_File_Transfer_Adapter_Http();
$this->objUpload->setOptions(array('useByteString' => false));
/**
* validators for upload of media
*/
$arrExcludedExtensions = $this->core->sysConfig->upload->excluded_extensions->extension->toArray();
$this->objUpload->addValidator('Size', false, array('min' => 1, 'max' => $this->core->sysConfig->upload->max_filesize));
$this->objUpload->addValidator('ExcludeExtension', false, $arrExcludedExtensions);
/**
* check if medium is uploaded
*/
if (!$this->objUpload->isUploaded(self::UPLOAD_FIELD)) {
$this->core->logger->warn('isUploaded: ' . implode('\\n', $this->objUpload->getMessages()));
throw new Exception('File is not uploaded!');
}
/**
* check if upload is valid
*/
if (!$this->objUpload->isValid(self::UPLOAD_FIELD)) {
$this->core->logger->warn('isValid: ' . implode('\\n', $this->objUpload->getMessages()));
throw new Exception('Uploaded file is not valid!');
}
}
示例6: uploadAction
public function uploadAction()
{
try {
if (empty($_FILES) || empty($_FILES['file']['name'])) {
throw new Exception($this->_("No file has been sent"));
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$data = $this->_getPackageDetails($file['file']['tmp_name']);
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$data = array("error" => 1, "message" => $e->getMessage());
}
$this->_sendHtml($data);
}
示例7: uploadAction
public function uploadAction()
{
if ($code = $this->getRequest()->getPost("code")) {
try {
if (empty($_FILES) || empty($_FILES['file']['name'])) {
throw new Exception("No file has been sent");
}
$path = Core_Model_Directory::getPathTo(System_Model_Config::IMAGE_PATH);
$base_path = Core_Model_Directory::getBasePathTo(System_Model_Config::IMAGE_PATH);
if (!is_dir($base_path)) {
mkdir($base_path, 0777, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($base_path);
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$config = new System_Model_Config();
$config->find($code, "code");
$config->setValue($path . DS . $file['file']['name'])->save();
$message = sprintf("Your %s has been successfully saved", $code);
$this->_sendHtml(array("success" => 1, "message" => $this->_($message)));
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$data = array("error" => 1, "message" => $e->getMessage());
}
}
}
示例8: uploadAction
public function uploadAction()
{
try {
if (empty($_FILES) || empty($_FILES['module']['name'])) {
throw new Exception("No file has been sent");
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
// $adapter->addValidator('MimeType', false, 'application/zip');
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$parser = new Installer_Model_Installer_Module_Parser();
if ($parser->setFile($file['module']['tmp_name'])->check()) {
$infos = pathinfo($file['module']['tmp_name']);
$filename = $infos['filename'];
$this->_redirect('installer/module/install', array('module_name' => $filename));
} else {
$messages = $parser->getErrors();
$message = implode("\n", $messages);
throw new Exception($this->_($message));
}
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$this->getSession()->addError($e->getMessage());
$this->_redirect('installer/module');
}
}
示例9: indexAction
/**
* indexAction
* @author Thomas Schedler <tsh@massiveart.com>
* @version 1.0
*/
public function indexAction()
{
try {
$this->core->logger->debug('media->controllers->UploadController->indexAction()');
$this->objUpload = new Zend_File_Transfer_Adapter_Http();
/**
* validators for upload of media
*/
$arrExcludedExtensions = $this->core->sysConfig->upload->excluded_extensions->extension->toArray();
$this->objUpload->addValidator('Size', false, array('min' => 1, 'max' => $this->core->sysConfig->upload->max_filesize));
$this->objUpload->addValidator('ExcludeExtension', false, $arrExcludedExtensions);
/**
* check if medium is uploaded
*/
if (!$this->objUpload->isUploaded(self::UPLOAD_FIELD)) {
$this->core->logger->warn('isUploaded: ' . implode('\\n', $this->objUpload->getMessages()));
throw new Exception('File is not uploaded!');
}
/**
* check if upload is valid
*/
// if (!$this->objUpload->isValid(self::UPLOAD_FIELD)) {
// $this->core->logger->warn('isValid: '.implode('\n', $this->objUpload->getMessages()));
// throw new Exception('Uploaded file is not valid!');
// }
if ($this->getRequest()->isPost()) {
$objRequest = $this->getRequest();
$this->intParentId = $objRequest->getParam('folderId');
/**
* check if is image or else document
*/
if ($this->intParentId > 0 && $this->intParentId != '') {
if (strpos($this->objUpload->getMimeType(self::UPLOAD_FIELD), 'image/') !== false) {
$this->handleImageUpload();
} else {
$this->handleFileUpload();
}
}
}
} catch (Exception $exc) {
$this->core->logger->err($exc);
}
}
示例10: indexAction
public function indexAction()
{
SxCms_Acl::requireAcl('filemanager', 'filemanager.index');
$base = APPLICATION_PATH . '/../public_html/files/';
$base = realpath($base);
$path = base64_decode($this->_getParam('path'));
if ($this->getRequest()->isPost()) {
if (null !== $this->_getParam('folder')) {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.folder');
if (strlen($this->_getParam('folder'))) {
$dirname = $path . '/' . $this->_getParam('folder');
mkdir($base . $dirname);
$this->_redirect('/admin/filemanager/index/path/' . base64_encode($path));
}
} else {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.file');
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(realpath($base) . $path);
if ($adapter->receive()) {
$filename = realpath($adapter->getFileName('filename'));
$file = new SxCms_File($filename);
$path = $file->getPathnameFromBase();
$nfile = $path . '/' . $file->getBasename();
$this->_redirect('/admin/filemanager/edit/file/' . base64_encode($nfile) . '/path/' . base64_encode($path));
} else {
$msg = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
$msg->addMessage('file', $adapter->getMessages());
}
}
}
$this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
try {
$it = new SxCms_Filesystem(realpath($base . $path));
} catch (Exception $e) {
$it = new SxCms_Filesystem($base);
$path = '';
$e;
}
$topdir = explode('/', $path);
if (count($topdir) > 1) {
array_pop($topdir);
$topdir = implode('/', $topdir);
} else {
$topdir = '';
}
$this->view->files = $it;
$this->view->path = $path;
$this->view->showpath = explode('/', $path);
$this->view->topdir = $topdir;
if ($this->_getParam('full')) {
$this->_helper->layout->setLayout('nolayout');
$this->view->full = true;
}
}
示例11: __construct
public function __construct($arrParam = array(), $options = null)
{
//////////////////////////////////
//Kiem tra Name /////////////
//////////////////////////////////
if ($arrParam['action'] == 'add') {
$options = array('table' => 'da_album', 'field' => 'album_name');
} elseif ($arrParam['action'] == 'edit') {
$options = array('table' => 'da_album', 'field' => 'album_name', 'exclude' => array('field' => 'id', 'value' => $arrParam['id']));
}
$validator = new Zend_Validate();
$validator->addValidator(new Zend_Validate_NotEmpty(), true)->addValidator(new Zend_Validate_StringLength(3, 100), true);
if (!$validator->isValid($arrParam['album_name'])) {
$message = $validator->getMessages();
$this->_messageError['album_name'] = 'Tên album: ' . current($message);
$arrParam['album_name'] = '';
}
//////////////////////////////////
//Kiem tra Picture small ///////////
//////////////////////////////////
$upload = new Zend_File_Transfer_Adapter_Http();
$fileInfo = $upload->getFileInfo('picture');
$fileName = $fileInfo['picture']['name'];
if (!empty($fileName)) {
$upload->addValidator('Extension', true, array('jpg', 'gif', 'png'), 'picture');
$upload->addValidator('Size', true, array('min' => '2KB', 'max' => '1000KB'), 'picture');
if (!$upload->isValid('picture')) {
$message = $upload->getMessages();
$this->_messageError['picture'] = 'Hình ảnh đại diện: ' . current($message);
}
}
//////////////////////////////////
//Kiem tra Order /////////////
//////////////////////////////////
$validator = new Zend_Validate();
$validator->addValidator(new Zend_Validate_StringLength(1, 10), true)->addValidator(new Zend_Validate_Digits(), true);
if (!$validator->isValid($arrParam['order'])) {
$message = $validator->getMessages();
$this->_messageError['order'] = 'Sắp xếp: ' . current($message);
$arrParam['order'] = '';
}
//////////////////////////////////
//Kiem tra Status /////////////
//////////////////////////////////
if (empty($arrParam['status']) || !isset($arrParam['status'])) {
$arrParam['status'] = 0;
}
//========================================
// TRUYEN CAC GIA TRI DUNG VAO MANG $_arrData
//========================================
$this->_arrData = $arrParam;
}
示例12: transferFile
public function transferFile()
{
if (!is_dir($this->_path)) {
mkdir($this->_path, 0777, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($this->_path);
if (!$adapter->receive()) {
$messages = $adapter->getMessages();
throw new Exception(implode("<br />", $messages));
}
return $adapter->getFileInfo();
}
示例13: _imageResizeAndSave
protected function _imageResizeAndSave($object)
{
$path = APPLICATION_ROOT . '/public_html/images/topcontentblock/';
$system->lng = $this->_getParam('lng');
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($path);
$adapter->setOptions(array('ignoreNoFile' => true));
if (!$adapter->receive()) {
$msgr = Sanmax_MessageStack::getInstance('SxModule_Topcontentblock_Validator');
$msgr->addMessage('file', $adapter->getMessages(), 'title');
}
if ($object->getPicture() == null) {
$object->setPicture('');
}
$files = $adapter->getFileInfo();
foreach ($files as $file) {
if (!$file['tmp_name']) {
continue;
}
$path0 = $path . "253X115/";
$path1 = $path . "1263X575/";
$path2 = $path . "1263X325/";
$filename = $object->createThumbName($file['name']) . '_' . time() . '.jpg';
$image = new Imagick($file['tmp_name']);
$image->cropThumbnailImage(253, 115);
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(100);
$image->setImageFormat('jpeg');
$image->writeImage($path0 . $filename);
$image->clear();
$image->destroy();
$image = new Imagick($file['tmp_name']);
$image->cropThumbnailImage(1263, 575);
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->setImageFormat('jpeg');
$image->writeImage($path1 . $filename);
$image->clear();
$image->destroy();
$image = new Imagick($file['tmp_name']);
$image->cropThumbnailImage(1263, 325);
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->setImageFormat('jpeg');
$image->writeImage($path2 . $filename);
$image->clear();
$image->destroy();
unlink($file['tmp_name']);
$object->setPicture($filename);
}
}
示例14: _imageResizeAndSave
protected function _imageResizeAndSave($object)
{
$path = APPLICATION_ROOT . '/public_html/images/eyecatchers/';
$system->lng = $this->_getParam('lng');
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($path);
$adapter->setOptions(array('ignoreNoFile' => true));
if (!$adapter->receive()) {
$msgr = Sanmax_MessageStack::getInstance('SxModule_Eyecatchers_Validator');
$msgr->addMessage('file', $adapter->getMessages(), 'title');
}
if ($object->getPicture() == null) {
$object->setPicture('');
}
$files = $adapter->getFileInfo();
foreach ($files as $file) {
if (!$file['tmp_name']) {
continue;
}
$path0 = $path . "253x115/";
$path1 = $path . "980x450/";
if (!is_dir($path0)) {
mkdir($path0, 0777, true);
}
if (!is_dir($path1)) {
mkdir($path1, 0777, true);
}
$filename = $object->createThumbName($file['name']) . '_' . time() . '.png';
$image = new Imagick($file['tmp_name']);
$image->cropThumbnailImage(253, 115);
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(100);
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->setImageFormat('png32');
$image->writeImage($path0 . $filename);
$image->clear();
$image->destroy();
$image = new Imagick($file['tmp_name']);
$image->cropThumbnailImage(980, 450);
$image->setCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(75);
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->setImageFormat('png32');
$image->writeImage($path1 . $filename);
$image->clear();
$image->destroy();
unlink($file['tmp_name']);
$object->setPicture($filename);
}
}
示例15: introasyncajaxAction
public function introasyncajaxAction()
{
$this->getResponse()->setHeader('Content-Type', 'application/json');
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
$params = $this->_getAllParams();
$intro = new Application_Model_O_GlobalConsultation();
$validate = new Yy_Validate_Value();
if ($validate->isValid($params['id'])) {
$intro->setId($params['id']);
} else {
$intro->setCtime(date('Y-m-d H:i:s'));
}
if ($validate->isValid($params['title'])) {
$intro->setTitle($params['title']);
}
if ($validate->isValid($params['content'])) {
$intro->setContent($params['content']);
}
if ($validate->isValid($params['sort'])) {
$intro->setSort($params['sort']);
}
if ($validate->isValid($params['status'])) {
$intro->setStatus($params['status']);
}
try {
$intro->save();
$id = $intro->getId();
$adapter = new Zend_File_Transfer_Adapter_Http();
$wrdir = Yy_Utils::getWriteDir();
$adapter->setDestination($wrdir);
if (!$adapter->receive()) {
$messages = $adapter->getMessages();
//echo implode("\n", $messages);
}
$filename = $adapter->getFileName();
if (is_string($filename)) {
$handle = fopen($filename, 'rb');
$img = addslashes(fread($handle, filesize($filename)));
fclose($handle);
Application_Model_M_GlobalConsultation::updateImage($id, $img);
}
$url = '/diagnosis/introview?id=' . $id;
$this->redirect($url);
} catch (Zend_Db_Exception $e) {
//$this->redirect('/error');
$this->redirect('/error?message=' . $e->getMessage());
}
}