php基于CodeIgniter实现图片上传、剪切功能的方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php基于CodeIgniter实现图片上传、剪切功能的方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1781字,纯文字阅读大概需要3分钟。
内容图文
![php基于CodeIgniter实现图片上传、剪切功能的方法](/upload/InfoBanner/zyjiaocheng/135/fb977fdc84b24d4d85d7c046867fe950.jpg)
具体内容如下
<?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手机短信验证码实现流程详解
php微信公众平台开发之微信群发信息实例分享
以上就是php基于CodeIgniter实现图片上传、剪切功能的方法的详细内容,更多请关注Gxl网其它相关文章!
内容总结
以上是互联网集市为您收集整理的php基于CodeIgniter实现图片上传、剪切功能的方法全部内容,希望文章能够帮你解决php基于CodeIgniter实现图片上传、剪切功能的方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。