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


PHP Utilities::resizeImagePercent方法代码示例

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


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

示例1: actionNewsSave

 public function actionNewsSave()
 {
     $pathImage = YiiBase::getPathOfAlias("webroot") . '/images';
     if (empty($_POST['id'])) {
         $news = new SacredNews();
     } else {
         $news = SacredNews::model()->findByPk($_POST['id']);
     }
     $utility = new Utilities();
     $currentDate = date('Ymd');
     if (!empty($_FILES['image']['name'])) {
         $subDerectoryMain = '/upload_news/' . $currentDate . '_';
         $imageName = $utility->resizeImagePercent($pathImage . $subDerectoryMain, $_FILES['image'], $this->resizeUpload);
         $news->news_img = $subDerectoryMain . $imageName;
     } else {
         $news->news_img = '';
     }
     $news->news_title = $_POST['title'];
     $news->news_detail = $_POST['detail'];
     $news->news_link = $_POST['link'];
     $news->news_updatedate = new CDbExpression('NOW()');
     if ($news->save(false)) {
         $this->redirect(array('sacred/indexNews'));
     } else {
         echo 'System Error';
     }
 }
开发者ID:pool13433,项目名称:yii-prakrueng,代码行数:27,代码来源:SacredController.php

示例2: actionUpload

 public function actionUpload($id = null)
 {
     if (empty($this->member->mem_id)) {
         Yii::app()->session['last_url'] = Yii::app()->createUrl('site/upload');
         $this->render('login');
     } else {
         if (empty($_POST)) {
             $listSacredType = SacredType::model()->findAll(array('order' => 'type_name'));
             $listRegion = Region::model()->findAll();
             /* $listProvince = Province::model()->findAll(array(                    
                //'condition' => 'reg_id = '.$this->regionDefault,
                'order' => 'pro_name_th'
                )); */
             if (empty($id)) {
                 $sacredObject = new SacredObject();
             } else {
                 $sacredObject = SacredObject::model()->findByPk($id);
             }
             $this->render('upload', array('listSacredType' => $listSacredType, 'listRegion' => $listRegion, 'sacredObject' => $sacredObject, 'sizeUpload' => $this->sizeUpload));
         } else {
             $this->member = Yii::app()->session['member'];
             if (empty($this->member)) {
                 echo CJSON::encode(array('status' => false, 'title' => 'ไม่สามารถลงปล่อยพระเครื่องให้เช่าได้', 'message' => 'ท่านยังไม่ได้ Login เข้าระบบ กรุณา Login เข้าระบบก่อน', 'url' => Yii::app()->createUrl('site/login')));
                 exit(0);
             } else {
                 $urlRedirect = Yii::app()->createUrl('site/index');
                 $currentDate = date('Ymd');
                 $pathImage = YiiBase::getPathOfAlias("webroot") . '/images';
                 $utility = new Utilities();
                 if (empty($_POST['id'])) {
                     $sacredObject = new SacredObject();
                     $sacredObject->obj_like = 0;
                 } else {
                     $urlRedirect = Yii::app()->createUrl('site/usersacredlist');
                     $sacredObject = SacredObject::model()->findByPk($_POST['id']);
                 }
                 $sacredObject->obj_born = $_POST['born'];
                 $sacredObject->obj_comment = $_POST['comment'];
                 $sacredObject->obj_location = $_POST['location'];
                 $sacredObject->obj_name = $_POST['name'];
                 $sacredObject->obj_price = $_POST['price'];
                 $sacredObject->pro_id = $_POST['province'];
                 $sacredObject->type_id = $_POST['type'];
                 $sacredObject->mem_id = $this->member->mem_id;
                 $sacredObject->obj_updatedate = new CDbExpression('NOW()');
                 if (!empty($_FILES['fileMain']['name'])) {
                     /*
                      * Manage Image Resize , Rename of File
                      */
                     $subDerectoryMain = '/upload_main/' . $currentDate . '_';
                     $imageName = $utility->resizeImagePercent($pathImage . $subDerectoryMain, $_FILES['fileMain'], $this->resizeUpload);
                     /*
                      * Manage Image Resize , Rename of File
                      */
                     $sacredObject->obj_img = $subDerectoryMain . $imageName;
                 }
                 if ($sacredObject->save(false)) {
                     if (!empty($_FILES['fileOther'])) {
                         $listFileOther = $this->readArrayFiles($_FILES['fileOther']);
                         foreach ($listFileOther as $index => $file) {
                             $sacredImg = new SacredObjectImg();
                             $sacredImg->img_size = $file['size'];
                             $sacredImg->img_ext = $file['type'];
                             $sacredImg->obj_id = $sacredObject->obj_id;
                             /*
                              * Manage Image Resize , Rename of File
                              */
                             $subDerectoryOther = '/upload_other/' . $currentDate . '_';
                             //$imageName = $utility->resizeImage($pathImage . $subDerectoryOther, $file, $this->imageWidth, $this->imageHeight);
                             $imageName = $utility->resizeImagePercent($pathImage . $subDerectoryOther, $file, $this->resizeUpload);
                             /*
                              * Manage Image Resize , Rename of File
                              */
                             $sacredImg->img_name = $subDerectoryOther . $imageName;
                             if (!$sacredImg->save(false)) {
                                 echo CJSON::encode(array('status' => false, 'title' => 'ไม่สามารถบันทึกได้', 'message' => 'ไม่สามารถบันทึก รูปภาพที่เกี่ยวข้องได้ กรุณาติดต่อ Admin Page', 'url' => ''));
                                 exit;
                             }
                         }
                     }
                     echo CJSON::encode(array('status' => true, 'title' => 'ลงข้อมูลปล่อยเช่าพระสำเร็จ', 'message' => 'ลงข้อมูลปล่อยเช่าพระสำเร็จ', 'url' => $urlRedirect));
                 }
             }
         }
     }
 }
开发者ID:pool13433,项目名称:yii-prakrueng,代码行数:86,代码来源:SiteController.php


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