PHP based on codeigniter implementation of image upload, clipping function,
This example for everyone to share the CodeIgniter picture upload, cut, controller class, for your reference, the specific content as follows
<?phpdefined (' BasePath ') or exit (' No Direct script access allowed '); class Index extends My_controller {function __cons Truct () {parent::__construct (); $this->load->helper (Array (' form ', ' url ')); }/** * Home */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_err ORS ()); $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); } }}
The above is the whole content of this article, I hope that you learn PHP programming help.
http://www.bkjia.com/PHPjc/1127901.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127901.html techarticle PHP based on codeigniter implementation of image upload, clipping function, this example for everyone to share the CodeIgniter picture upload, cut, controller class, for your reference, the specific content as follows Phpde ...