Php implements image upload and cropping based on CodeIgniter ,. Php implements image upload and cropping based on CodeIgniter. examples in this article share with you the codeigniter image upload, cropping, and controller classes for your reference, the specific content is as follows: php uses CodeIgniter to upload and cut images,
This article provides examples of codeigniter Image uploading, cropping, and controller classes for your reference. the specific content is as follows:
<? Phpdefined ('basepath') OR exit ('no direct script access allowed'); class Index extends MY_Controller {function _ construct () {parent :__ construct (); $ this-> load-> helper (array ('form', 'URL');}/*** homepage */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 );}}}
The above is all the content of this article. I hope it will help you learn php programming.
Examples in this article share the codeigniter image upload, cropping, and controller classes for your reference. the specific content is as follows: phpdde...