本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::isValid方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::isValid怎么用?PHP Zend_File_Transfer_Adapter_Http::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadAjaxAction
public function uploadAjaxAction()
{
$this->_helper->layout->setLayout('ajax');
$data = $this->_request->getPost();
$extraDados = "";
if (isset($data['id'])) {
$extraDados = $data['id'] . '-';
}
$path = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'uploads';
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($path);
// Returns all known internal file information
$files = $upload->getFileInfo();
foreach ($files as $file => $info) {
// Se não existir arquivo para upload
if (!$upload->isUploaded($file)) {
print '<p class="alert alert-warning">Nenhum arquivo selecionado para upload<p>';
continue;
} else {
$fileName = $extraDados . str_replace(' ', '_', strtolower($info['name']));
// Renomeando o arquivo
$upload->addFilter('Rename', array('target' => $path . DIRECTORY_SEPARATOR . $fileName, 'overwrite' => true));
}
// Validação do arquivo ?
if (!$upload->isValid($file)) {
print '<p class="alert alert-danger" > <b>' . $file . '</b>. Arquivo inválido </p>';
continue;
} else {
if ($upload->receive($info['name'])) {
print '<p class="alert alert-success"> Arquivo: <b>' . $info['name'] . '</b> enviado com sucesso e renomeado para: <b>' . $fileName . '</b> </p>';
}
}
}
}
示例2: handleUpload
/**
* @param string $attributeCode
* @param string $type
* @return bool
*/
protected static function handleUpload($attributeCode, $type)
{
if (!isset($_FILES)) {
return false;
}
$adapter = new Zend_File_Transfer_Adapter_Http();
if ($adapter->isUploaded('typecms_' . $attributeCode . '_')) {
if (!$adapter->isValid('typecms_' . $attributeCode . '_')) {
Mage::throwException(Mage::helper('typecms')->__('Uploaded ' . $type . ' is invalid'));
}
$upload = new Varien_File_Uploader('typecms[' . $attributeCode . ']');
$upload->setAllowCreateFolders(true);
if ($type == 'image') {
$upload->setAllowedExtensions(array('jpg', 'gif', 'png'));
}
$upload->setAllowRenameFiles(true);
$upload->setFilesDispersion(false);
try {
if ($upload->save(Mage::helper('typecms')->getBaseImageDir())) {
return $upload->getUploadedFileName();
}
} catch (Exception $e) {
Mage::throwException('Uploaded ' . $type . ' is invalid');
}
}
return false;
}
示例3: 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!');
}
}
示例4: _uploadPlugin
private function _uploadPlugin()
{
$this->_uploadHandler->addValidator('Extension', false, 'zip');
if ($this->_checkMime) {
$this->_uploadHandler->addValidator(new Validators_MimeType(array('application/zip')), false);
}
$pluginArchive = $this->_uploadHandler->getFileInfo();
if (!$this->_uploadHandler->isValid()) {
return array('error' => true);
}
$destination = $this->_uploadHandler->getDestination();
$zip = new ZipArchive();
$zip->open($pluginArchive['file']['tmp_name']);
$unzipped = $zip->extractTo($destination);
if ($unzipped !== true) {
return array('name' => $pluginArchive['file']['name'], 'error' => 'Can\'t extract zip file to tmp directory');
}
$pluginName = str_replace('.zip', '', $pluginArchive['file']['name']);
$validateMessage = $this->_validatePlugin($pluginName);
$miscConfig = Zend_Registry::get('misc');
if ($validateMessage === true) {
$destinationDir = $this->_websiteConfig['path'] . $miscConfig['pluginsPath'];
if (is_dir($destinationDir . $pluginName)) {
Tools_Filesystem_Tools::deleteDir($destinationDir . $pluginName);
}
$res = $zip->extractTo($destinationDir);
$zip->close();
Tools_Filesystem_Tools::deleteDir($destination . '/' . $pluginName);
} else {
$zip->close();
return array('name' => $pluginArchive['file']['name'], 'error' => $validateMessage);
}
return array('error' => false, 'name' => $pluginArchive['file']['name'], 'type' => $pluginArchive['file']['type'], 'size' => $pluginArchive['file']['size'], 'pluginname' => $pluginName);
}
示例5: imageAction
public function imageAction()
{
if ($this->getRequest()->isPost()) {
$upload = new Zend_File_Transfer_Adapter_Http();
$dirs = array('image' => array('gif', 'jpg', 'jpeg', 'png'), 'flash' => array('swf', 'flv'));
$dir = $this->_getParam('dir');
if (!isset($dirs[$dir])) {
$this->_alert('上传类型出错!');
}
$savePath = UPLOAD_PATH . DS . $dir;
//检查文件大小
$upload->addValidator('Size', false, 500000);
if (false == $upload->isValid()) {
$this->_alert('上传文件大小超过500KB限制。');
}
//检查目录
if (@is_dir($savePath) === false) {
$this->_alert('上传目录不存在。');
}
//检查目录写权限
if (@is_writable($savePath) === false) {
$this->_alert('上传目录没有写权限。');
}
//获得文件类型
$upload->addValidator('Extension', false, $dirs[$dir]);
if (false == $upload->isValid()) {
$this->_alert('只能上传' . implode('、', $dirs[$dir]) . '文件类型');
}
//设置保存的Path
$upload->setDestination($savePath);
//设置新的文件名
$fileInfo = $upload->getFileInfo();
$tmpFile = $fileInfo['imgFile']['name'];
$extension = explode('.', $tmpFile);
$extension = array_pop($extension);
$newFile = md5($tmpFile . uniqid()) . '.' . $extension;
$upload->addFilter('Rename', array('target' => $savePath . DS . $newFile, 'overwrite' => true));
//保存文件
$upload->receive();
//返回文件url
echo Zend_Json::encode(array('error' => 0, 'url' => $this->view->baseUrl() . '/uploads/image/' . $newFile));
exit;
} else {
$this->_alert('请选择文件。');
exit;
}
}
示例6: 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;
}
示例7: uploadPreviewImage
/**
* Upload preview image
*
* @param string $scope the request key for file
* @param string $destinationPath path to upload directory
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function uploadPreviewImage($scope, $destinationPath)
{
if (!$this->_transferAdapter->isUploaded($scope)) {
return false;
}
if (!$this->_transferAdapter->isValid($scope)) {
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Uploaded image is not valid'));
}
$upload = $this->_uploaderFactory->create(['fileId' => $scope]);
$upload->setAllowCreateFolders(true);
$upload->setAllowedExtensions($this->_allowedExtensions);
$upload->setAllowRenameFiles(true);
$upload->setFilesDispersion(false);
if (!$upload->checkAllowedExtension($upload->getFileExtension())) {
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Invalid image file type.'));
}
if (!$upload->save($destinationPath)) {
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Image can not be saved.'));
}
return $destinationPath . '/' . $upload->getUploadedFileName();
}
示例8: __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;
}
示例9: 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));
}
}
示例10: addAction
public function addAction()
{
$userNs = new Zend_Session_Namespace("members");
$this->view->title = "City - Add";
$this->view->headTitle(" - " . $this->view->title);
$form = new Admin_Form_City();
$this->view->form = $form;
$this->view->successMsg = "";
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$upload = new Zend_File_Transfer_Adapter_Http();
//---main image
if ($upload->isValid('logo')) {
$upload->setDestination("images/logo/");
try {
$upload->receive('logo');
} catch (Zend_File_Transfer_Exception $e) {
$msg = $e->getMessage();
}
$upload->setOptions(array('useByteString' => false));
$id = time();
$file_name = $upload->getFileName('logo');
$cardImageTypeArr = explode(".", $file_name);
$ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
$target_file_name = "logo_" . $id . ".{$ext}";
$targetPath = 'media/picture/city/logo/' . $target_file_name;
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
$filterFileRename->filter($file_name);
$formData['logo'] = $target_file_name;
/*--- Generate Thumbnail ---*/
$thumb = Base_Image_PhpThumbFactory::create($targetPath);
$thumb->resize(100, 100);
$thumb->save($targetPath = 'media/picture/city/logo/thumb_' . $target_file_name);
}
$usersNs = new Zend_Session_Namespace("members");
$formData['userId'] = $usersNs->userId;
$this->view->warningMsg = '';
$model = new Application_Model_City($formData);
$id = $model->save($model);
$form->reset();
$this->view->successMsg = "City added successfully. City Id : {$id}";
} else {
$form->populate($formData);
}
}
}
示例11: uploadAction
public function uploadAction()
{
$request = $this->getRequest();
$table = new Model_DbTable_Sheets();
$select = $table->select();
$select->where('id = ?', $request->id);
$sheet = $table->fetchRow($select);
if (!$this->view->authenticated || $sheet->user_id != $this->view->identity->id) {
$this->_redirector->gotoRoute(array(), 'login');
}
if ($request->isPost()) {
$path = UPLOAD_PATH . '/sheets/';
if (!file_exists($path)) {
mkdir(str_replace('//', '/', $path), 0755, true);
}
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($path);
$upload->addValidators(array(array('Count', false, 5), array('Size', false, '2MB'), array('Extension', false, array('pdf', 'midi', 'mid'))));
if ($upload->isValid()) {
$table = new Model_DbTable_Downloads();
$pattern = array('/-/', '/_/', '/\\s+/');
$replace = array(' - ', ' ', ' ');
foreach ($upload->getFileInfo() as $file => $contents) {
$info = pathinfo($contents['name']);
$row = $table->createRow();
$row->sheet_id = $sheet->id;
$row->type = strtolower($info['extension']) == 'pdf' ? 'PDF' : 'MIDI';
$title = preg_replace($pattern, $replace, $info['filename']);
$row->title = ucwords($title);
$row->save();
$name = $row->id . ($row->type == 'MIDI' ? '.mid' : '.pdf');
$upload->addFilter('Rename', array('target' => $name), $file);
$upload->receive($file);
}
if ($upload->isReceived()) {
return $this->_redirector->gotoRoute(array('controller' => 'sheet', 'id' => $request->id), 'view');
}
}
$this->view->errors = $upload->getMessages();
}
$this->view->headTitle('Upload sheet file(s)');
$this->view->headScript()->appendFile('/js/multifile.js');
$this->view->headScript()->appendFile('/js/upload.js');
$this->view->sheetId = $request->id;
}
示例12: upload
private function upload()
{
$todir = $this->_cfg['temp']['path'] . $this->getRequest()->getParam('docid', 'unknown_doc');
if (!file_exists($todir)) {
mkdir($todir);
}
$adapter = new Zend_File_Transfer_Adapter_Http(array('ignoreNoFile' => true));
$filename = $adapter->getFileName('upload', false);
$adapter->addValidator('Extension', false, $this->getRequest()->getParam('type') == 'images' ? $this->imgExts : $this->fileExts)->addValidators($this->getRequest()->getParam('type') == 'images' ? $this->imgValidators : $this->fileValidators)->addFilter('Rename', array('target' => $todir . DIRECTORY_SEPARATOR . iconv('utf-8', FS_CHARSET, $filename), 'overwrite' => true));
// $adapter->setDestination($todir);
$result = new stdClass();
$result->messages = array();
$result->uploadedUrl = '';
if (!$adapter->isValid()) {
$result->messages = $adapter->getMessages();
} else {
if ($adapter->receive() && $adapter->isUploaded()) {
$result->uploadedUrl = ($this->getRequest()->getParam('type') == 'images' ? '' : 'downloads/') . $filename;
}
}
$result->CKEditorFuncNum = $this->getRequest()->getParam('CKEditorFuncNum');
return $result;
}
示例13: uploadFiles
/**
*
* @return array
*/
public function uploadFiles()
{
$return = array('files' => array());
try {
$dir = $this->getDirDocs();
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($dir);
$typeValidator = new Zend_Validate_File_Extension($this->_extensions);
$sizeFile = new Zend_Validate_File_Size($this->_maxSize);
$adapter->addValidator($typeValidator, true)->addValidator($sizeFile, true);
$files = $adapter->getFileInfo();
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
continue;
}
$name = $this->_getNewFileName($dir, $info['name']);
$fileInfo = array('size' => $info['size'], 'name' => $name);
if (!$adapter->isValid($file)) {
$messages = $adapter->getMessages();
$fileInfo['error'] = array_shift($messages);
$return['files'][] = $fileInfo;
continue;
}
$adapter->addFilter('Rename', $dir . $name, $file);
$adapter->receive($file);
$pathFile = $this->publicFileUrl($dir . $name);
$fileInfo['url'] = $pathFile;
$fileInfo['delete_url'] = '/client/document/delete/?file=' . $pathFile;
$fileInfo['delete_type'] = 'DELETE';
$return['files'][] = $fileInfo;
}
return $return;
} catch (Exception $e) {
return $return;
}
}
示例14: addCountryImageEXPAction
public function addCountryImageEXPAction()
{
$this->_helper->layout->disableLayout();
//$this->_helper->viewRenderer->setNoRender(true);
//get request variables
$id = $this->_getParam("id");
$page = $this->_getParam("page");
$selTab = $this->_getParam("tab", "tabs-7");
$this->view->cityId = $id;
//create image upload form
$uploadForm = new Admin_Form_CityImages();
$elements = $uploadForm->getElements();
$uploadForm->clearDecorators();
foreach ($elements as $element) {
$element->removeDecorator('label');
$element->removeDecorator('td');
$element->removeDecorator('tr');
$element->removeDecorator('row');
$element->removeDecorator('HtmlTag');
$element->removeDecorator('placement');
$element->removeDecorator('data');
}
$this->view->uploadForm = $uploadForm;
//selects country images to edit
$oldImageArr = array();
$oldImageSortingArr = array();
$lonelyPlanetCountryM = new Application_Model_LonelyPlanetCountry();
$lonelyPlanetCountryM = $lonelyPlanetCountryM->find($id);
if (false !== $lonelyPlanetCountryM) {
$oldImageArr = unserialize($lonelyPlanetCountryM->getImages());
//echo "<pre>";
//print_r($oldImageArr);
for ($oCnt = 0; $oCnt < count($oldImageArr); $oCnt++) {
$imgArr = $oldImageArr[$oCnt];
$imgArr["alt_text"] = "";
$imgArr["slide_link_url"] = "";
$imgArr["slide_link_target"] = "";
$imgArr["weight"] = $oCnt + 1;
$oldImageSortingArr[] = $imgArr;
}
//print_r($oldImageSortingArr);
//echo "</pre>";
//exit;
}
$request = $this->getRequest();
if ($request->isPost()) {
$options = $request->getPost();
if ($uploadForm->isValid($options)) {
$target_file_name = "";
//Upload image strat here
$upload = new Zend_File_Transfer_Adapter_Http();
if ($upload->isValid()) {
$upload->setDestination("media/picture/country/");
try {
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$msg = $e->getMessage();
}
$upload->setOptions(array('useByteString' => false));
$file_name = $upload->getFileName('countryImage');
$cardImageTypeArr = explode(".", $file_name);
$ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
$target_file_name = "country{$country_id}_" . time() . ".{$ext}";
$targetPath = "media/picture/country/images/" . $target_file_name;
$targetPathThumb = "media/picture/country/images/thumbs/" . $target_file_name;
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
$filterFileRename->filter($file_name);
$thumb = Base_Image_PhpThumbFactory::create($targetPath);
$thumb->resize(625, 330);
$thumb->save($targetPathThumb);
}
//end if
//upload image Ends here
//set country Image array
$addImageArr = array();
$addImageArr["image_caption"] = $options["slideTitle"];
$addImageArr["image_photographer"] = "Gap Daemon";
$addImageArr["image_filename"] = "/images/" . $target_file_name;
$addImageArr["image_thumbnail_filename"] = "/images/thumbs/" . $target_file_name;
$addImageArr["alt_text"] = $options["altText"];
$addImageArr["slide_link_url"] = $options["slideLinkUrl"];
$addImageArr["slide_link_target"] = $options["slideLinkTarget"];
$addImageArr["weight"] = $options["weight"];
$oldImageSortingArr[count($oldImageSortingArr)] = $addImageArr;
$newCountryImageArr = serialize($oldImageSortingArr);
$lonelyPlanetCountryM->setImages($newCountryImageArr);
$resImg = $lonelyPlanetCountryM->save();
if ($resImg) {
$_SESSION['errorMsg'] = "Images has been saved successfully.";
echo "<script>window.opener.location='/admin/featured-city/edit-country/id/{$id}/page/{$page}/tab/{$selTab}';</script>";
echo "<script>window.close();</script>";
} else {
$this->view->errorMsg = "Error occured, please try again later.";
}
} else {
$uploadForm->reset();
$uploadForm->populate($options);
}
}
//end if
//.........这里部分代码省略.........
示例15: isValidParent
public function isValidParent($files = null)
{
return parent::isValid($files);
}