PHP implementation of image upload, clipping function php image upload class php mobile upload images php Mobile upload image

Source: Internet
Author: User
Tags learn php learn php programming php programming
This article is a detailed introduction of the PHP implementation of the image upload, clipping function of the specific code for your reference, the specific content 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 '));  }/** * 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.

The above describes the PHP implementation of the image upload, clipping, including the image upload, PHP content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.