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


PHP wbUtil::createThumbnailImage方法代码示例

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


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

示例1: update

 /**
  * update
  * controler for update item
  */
 public static function update($args = array())
 {
     // Security check
     //if (!wbSecurity::check('DHotel')) return;
     // Get arguments from argument array
     global $_FILES;
     if (!empty($_FILES['file_name']['name'])) {
         try {
             wbUtil::checkUploadedImage($_FILES['file_name']);
         } catch (Exception $e) {
             $data['message'] = $e->getMessage();
             echo json_encode($data);
             session_write_close();
             exit;
         }
     }
     $jsonItems = wbRequest::getVarClean('items', 'str', '');
     $items =& wbUtil::jsonDecode($jsonItems);
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     try {
         $ws_client = self::getNusoap();
         ///////////////////////////////////this is the magic for upload////////////////////////////////////
         $tmpfile = $_FILES['file_name']['tmp_name'];
         $handle = fopen($tmpfile, "r");
         // Open the temp file
         $contents = fread($handle, filesize($tmpfile));
         // Read the temp file
         fclose($handle);
         // Close the temp file
         $decodeContent = base64_encode($contents);
         $_POST['uploaded']['file_name'] = $decodeContent;
         ///////////////////////////////////////////////////////////////////////////////////////////////////
         $params = array('search' => '', 'getParams' => json_encode($_GET), 'controller' => json_encode(array('module' => 'bds', 'class' => 't_cust_order_legal_doc', 'method' => 'update', 'type' => 'json')), 'postParams' => json_encode($_POST), 'jsonItems' => '', 'start' => $start, 'limit' => $limit);
         $ws_data = self::getResultData($ws_client, $params);
         if ($ws_data['success']) {
             try {
                 if (!empty($_FILES['file_name']['name'])) {
                     $r = $ws_data['data']['old_row'];
                     if (!empty($r['origin_file_name']) && is_file(self::imurl() . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name'])) {
                         @unlink(self::imurl() . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name']);
                         if (is_file(self::imurl() . 'th_' . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name'])) {
                             @unlink(self::imurl() . 'th_' . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name']);
                         }
                         if (is_file(self::imurl() . 'view_' . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name'])) {
                             @unlink(self::imurl() . 'view_' . $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . $r['origin_file_name']);
                         }
                     }
                     $filename = $ws_data['data']['t_cust_order_legal_doc_id'] . '_' . str_replace(' ', '_', $_FILES['file_name']['name']);
                     if (!move_uploaded_file($_FILES['file_name']['tmp_name'], self::imurl() . $filename)) {
                         throw new Exception("Upload file gagal. Mohon periksa direktori bukti transfer");
                     }
                     $path = strtolower(strrchr($_FILES['file_name']['name'], '.'));
                     if ($path == '.jpeg' || $path == '.jpg' || $path == '.gif' || $path == '.png') {
                         $thumbnail = self::imurl() . '/th_' . $filename;
                         wbUtil::createThumbnailImage(2, self::imurl() . $filename, $thumbnail, 150, 150);
                         $view_picture = self::imurl() . '/view_' . $filename;
                         wbUtil::createThumbnailImage(2, self::imurl() . $filename, $view_picture, 600, 800);
                     }
                     $data['items'] = $ws_data['data'];
                     $data['total'] = $ws_data['total'];
                     $data['message'] = $ws_data['message'];
                     $data['success'] = $ws_data['success'];
                 }
             } catch (Exception $e) {
                 $data['total'] = 0;
                 $data['message'] = $e->getMessage();
                 $data['items'] = $items;
             }
         }
     } catch (Exception $e) {
         $data['message'] = $e->getMessage();
     }
     echo json_encode($data);
     exit;
 }
开发者ID:rayminami,项目名称:mpd-wp,代码行数:79,代码来源:t_cust_order_legal_doc_controller.php

示例2: update

 /**
  * update
  * controler for update item
  */
 public static function update($args = array())
 {
     // Security check
     //if (!wbSecurity::check('DHotel')) return;
     // Get arguments from argument array
     extract($args);
     $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => '');
     $jsonItems = wbRequest::getVarClean('items', 'str', '');
     $items =& wbUtil::jsonDecode($jsonItems);
     $t_cust_order_legal_doc_id = wbRequest::getVarClean('t_cust_order_legal_doc_id', 'int', 0);
     $t_customer_order_id = wbRequest::getVarClean('t_customer_order_id', 'int', 0);
     $p_legal_doc_type_id = wbRequest::getVarClean('p_legal_doc_type_id', 'str', '');
     $legal_doc_desc = wbRequest::getVarClean('legal_doc_desc', 'str', '');
     $origin_file_name = wbRequest::getVarClean('file_name', 'str', '');
     $file_folder = wbRequest::getVarClean('file_folder', 'int', 0);
     $file_name = wbRequest::getVarClean('file_name', 'int', 0);
     $jsonItems = wbRequest::getVarClean('items', 'str', '');
     if (!is_array($items)) {
         $data['message'] = 'Invalid items parameter';
         return $data;
     }
     $table =& wbModule::getModel('bds', 't_cust_order_legal_doc');
     $table->actionType = 'UPDATE';
     $old_row = $table->Get($items['t_cust_order_legal_doc_id']);
     if (isset($items[0])) {
         $errors = array();
         $numSaved = 0;
         $numItems = count($items);
         $savedItems = array();
         for ($i = 0; $i < $numItems; $i++) {
             try {
                 $table->setRecord($items[$i]);
                 $table->update();
                 $numSaved++;
             } catch (Exception $e) {
                 $errors[] = $e->getMessage();
             }
             $items[$i] = array_merge($items[$i], $table->record);
         }
         $numErrors = count($errors);
         if (count($errors)) {
             $data['message'] = $numErrors . " dari " . $numItems . " record gagal di-update.<br/><br/><b>System Response:</b><br/>- " . implode("<br/>- ", $errors) . "";
         } else {
             $data['success'] = true;
             $data['message'] = 'Data berhasil di-update';
         }
         $data['items'] = $items;
     } else {
         try {
             $items['file_name'] = time() . $items['file_name'];
             $table->setRecord($items);
             $table->update();
             $r = $old_row;
             if (!empty($r['file_name'])) {
                 print_r($r['file_name']);
                 @unlink(self::unlinkurl() . $r['file_name']);
             }
             if (!empty($_FILES['uploadedfile']['name'])) {
                 $orign_filename = $_FILES['uploadedfile']['name'];
                 $filename = time() . $_FILES['uploadedfile']['name'];
                 if (!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], self::imurl() . $filename)) {
                     throw new Exception("Upload file gagal. Mohon periksa direktori bukti transfer");
                 }
                 $path = strtolower(strrchr($_FILES['uploadedfile']['name'], '.'));
                 if ($path == '.jpeg' || $path == '.jpg' || $path == '.gif' || $path == '.png') {
                     $thumbnail = self::imurl() . '/th_' . $filename;
                     wbUtil::createThumbnailImage(2, self::imurl() . $filename, $thumbnail, 150, 150);
                     $view_picture = self::imurl() . '/view_' . $filename;
                     wbUtil::createThumbnailImage(2, self::imurl() . $filename, $view_picture, 600, 800);
                 }
             }
             ///////////////////////////////////this is the magic for upload////////////////////////////////////
             //$encoded = $_POST['uploaded']->file_name;
             //$location = self::imurl().$items[$table->pkey].'_'.$items['file_name'];// Mention where to upload the file
             //$current = @file_get_contents($location);                     // Get the file content. This will create an empty file if the file does not exist
             //$current = base64_decode($encoded);                          // Now decode the content which was sent by the client
             //file_put_contents($location, $current);                      // Write the decoded content in the file mentioned at particular location
             ///////////////////////////////////////////////////////////////////////////////////////////////////
             $data['success'] = true;
             $data['message'] = 'Data berhasil di-update';
         } catch (Exception $e) {
             $data['message'] = $e->getMessage();
         }
         $data['items'] = array_merge($items, $table->record, array('old_row' => $old_row));
     }
     return $data;
 }
开发者ID:rayminami,项目名称:mpd-wp,代码行数:91,代码来源:upload_doc_local_controller.php


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