中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

php實現圖片上傳/剪切功能
來源:易賢網 閱讀:1588 次 日期:2016-08-24 14:53:49
溫馨提示:易賢網小編為您整理了“php實現圖片上傳/剪切功能”,方便廣大網友查閱!

本文實例為大家詳細介紹了php實現圖片上傳、剪切功能的具體代碼,供大家參考,具體內容如下

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Index extends MY_Controller {

  function __construct(){

    parent::__construct();

    $this->load->helper(array('form', 'url'));

  }

  /**

   * 首頁

   */

  public function index() {

    $this->load->view('upload_form', array('error' => ' ' ));

  }

  public function do_upload()

  {

    $config['upload_path']   = './data/uploads/';

    $config['allowed_types']  = 'gif|jpg|png';

    $config['max_size']   = 100;

    $config['max_width']    = 1024;

    $config['max_height']    = 768;

    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload('userfile'))

    {

      $error = array('error' => $this->upload->display_errors());

      $this->load->view('upload_form', $error);

    }

    else

    {

      $data = array('upload_data' => $this->upload->data());

        

      $this->load->library('image_lib');      

      list($width, $height) = getimagesize($data['upload_data']['full_path']);

      $config['image_library'] = 'gd2';

      $config['source_image'] = $data['upload_data']['full_path'];

      $config['maintain_ratio'] = TRUE;

      if($width >= $height)

      {

        $config['master_dim'] = 'height';

      }else{

        $config['master_dim'] = 'width';

      }

      $config['width'] = 180;

      $config['height'] = 180;

      $this->image_lib->initialize($config);

      $this->image_lib->resize();

      

      $config['maintain_ratio'] = FALSE;

      if($width >= $height)

      {

        $config['x_axis'] = floor(($width * 180 / $height - 180)/2);

      }else{

        $config['y_axis'] = floor(($height * 180 / $width - 180)/2);

      }

      $this->image_lib->initialize($config);

      $this->image_lib->crop();

        

      $this->load->view('upload_success', $data);

    }

  }

}

以上就是本文的全部內容,希望對大家學習php程序設計有所幫助。

更多信息請查看網絡編程
易賢網手機網站地址:php實現圖片上傳/剪切功能
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
主站蜘蛛池模板: 方正县| 军事| 个旧市| 宁都县| 孝感市| 柏乡县| 永宁县| 信宜市| 金川县| 睢宁县| 鹤壁市| 大埔区| 龙门县| 平果县| 开平市| 札达县| 上饶市| 马鞍山市| 光泽县| 临西县| 木兰县| 盘山县| 德清县| 建瓯市| 龙川县| 始兴县| 东阿县| 芮城县| 长海县| 邮箱| 太湖县| 汽车| 肇东市| 拜城县| 德庆县| 东明县| 临澧县| 瑞金市| 泰来县| 鞍山市| 金门县|