/** * 不入数据库的上传 * 不做压缩和缩略图处理 */ public function actionSimpleUpload() { $uptype = zmf::filterInput($_GET['type'], 't', 1); $fileholder = zmf::filterInput($_GET['fileholder'], 't', 1); //上传控件的ID $fileName = zmf::filterInput($_GET['fileName'], 't', 1); //上传后保存名字 $keyid = zmf::filterInput($_GET['keyid']); //所属对象ID if (!isset($uptype) or !in_array($uptype, array('topArea', 'avatar'))) { $this->jsonOutPut(0, '请设置上传所属类型' . $uptype); } if (Yii::app()->request->getParam('PHPSESSID')) { Yii::app()->session->close(); Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID')); Yii::app()->session->open(); } if (Yii::app()->user->isGuest) { $this->jsonOutPut(0, Yii::t('default', 'loginfirst')); } if ($uptype == 'avatar' && !$keyid) { $this->jsonOutPut(0, '缺少参数'); } $checkInfo = UserPower::check('addImage', true); if (!$checkInfo['status']) { $this->jsonOutPut(0, $checkInfo['msg']); } if (!$fileholder) { $fileholder = 'filedata'; } if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) { $this->jsonOutPut(0, '无效上传,请重试'); } $img = CUploadedFile::getInstanceByName($fileholder); $ext = $img->getExtensionName(); $size = $img->getSize(); if ($size > zmf::config('imgMaxSize')) { $this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize'))); } $upExt = zmf::config("imgAllowTypes"); if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) { $this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt); } if (!$fileName) { $fileName = uniqid() . '.' . $ext; } if ($uptype == 'avatar') { $fileName = $keyid . '.jpg'; } if ($uptype == 'topArea') { $todir = zmf::attachBase('app') . '/daodao/'; $returnDir = zmf::attachBase('site') . '/daodao/'; } elseif ($uptype == 'avatar') { $todir = zmf::attachBase('app') . '/avatar/origin/' . $keyid . '/'; $todir2 = zmf::attachBase('app') . '/avatar/big/' . $keyid . '/'; $todir3 = zmf::attachBase('app') . '/avatar/small/' . $keyid . '/'; $returnDir = zmf::attachBase('site') . '/avatar/small/' . $keyid . '/'; } zmf::createUploadDir($todir); if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $todir . $fileName)) { if ($uptype == 'avatar') { $image = Yii::app()->image->load($todir . $fileName); zmf::createUploadDir($todir2); zmf::createUploadDir($todir3); $image->smart_resize(100, 100)->quality(95); $image->save($todir2 . $fileName); $image->smart_resize(50, 50)->quality(95); $image->save($todir3 . $fileName); } $outPutData = array('status' => 1, 'imgsrc' => $returnDir . $fileName, 'attachid' => ''); $json = CJSON::encode($outPutData); echo $json; } else { $this->jsonOutPut(0, '上传失败'); } }
</li> </ul> <?php } ?> </div> </div> </div> <?php $this->renderPartial('/index/floatNav'); if (Yii::app()->getController()->id == 'index' && in_array(Yii::app()->getController()->getAction()->id, array('index'))) { ?> <div class="header-ppt"> <div class="header-bg"> <img id="backdrop" class="lazy" data-original="<?php echo zmf::attachBase('site'); ?> daodao/bg.jpg" src="<?php echo zmf::lazyImg(); ?> " width="100%" /> </div> <div class="header-search-bg"></div> <div class="header-search"> <div class="search-login" id="main-search-holder"> <h1 class="logo-title text-center">完美你的旅行计划</h1> <form role="form" action="<?php echo zmf::config("domain") . Yii::app()->createUrl("posts/search"); ?> " method="GET"> <div class="input-group">
/** * 返回地区或国家所用标识 * @param type $info * @return string */ public static function getLogo($info) { if (!$info['logo']) { return zmf::noImg('url'); } $todir = zmf::attachBase('app') . '/area/' . $info['logo']; $returnDir = zmf::attachBase('site') . '/area/' . $info['logo']; if (file_exists($todir)) { return $returnDir; } return zmf::noImg('url'); }