thinkphp thumbnail image

Source: Internet
Author: User

<?PHPclassIndexactionextendsAction { Public functionindex () {$Photo= M (' Photo '); $list=$Photo->order (' create_time desc ')->limit (2)Select (); $this->assign (' list ',$list); $this-display (); }      Public functionupload () {if(!Empty($_files)) {             //If there is a file upload upload attachment            $this-_upload (); //$this->forward ();        }     }     //File Upload    protected function_upload () {//I'm using a ORG.Net.UploadFile.Import ("@.org.uploadfile"); //Import Upload Class        $upload=NewUploadFile (); //Set upload file size        $upload->maxsize = 3292200; //set upload file type        $upload->allowexts =Explode(', ', ' jpg,gif,png,jpeg '); //Set Attachments upload directory        $upload->savepath = '/thinkphp/examples/file/tpl/public/uploads/'; //settings need to generate thumbnails, only valid for image files        $upload->thumb =true; //Set the Reference Picture Class Library package path I'm using ORG.Util.UploadFile.        $upload->imageclasspath = ' @.org.image '; //set the file suffix to generate thumbnails        $upload->thumbprefix = ' M_,s_ ';//production of 2 thumbnails//set thumbnail maximum width        $upload->thumbmaxwidth = ' 400,100 '; //set thumbnail maximum height        $upload->thumbmaxheight = ' 400,100 '; //set upload file rules        $upload->saverule =uniqid; //Delete Original        $upload->thumbremoveorigin =true; if(!$upload-upload ()) {             //Capturing upload Exceptions            $this->error ($upload-geterrormsg ()); } Else {             //get file information for successful uploads            $uploadList=$upload-Getuploadfileinfo (); //ORG. Util.uploadfileImport ("@.org.image"); //add watermark to m_ thumbnail, image::water (' original filename ', ' watermark Image address ')Image::water ($uploadList[0] [' Savepath ']. ' M_ '.$uploadList[0] [' Savename '], '/thinkphp/examples/file/tpl/public/images/logo2.png '); $_post[' image '] =$uploadList[0] [' Savename ']; }         $model= M (' Photo '); //Save current data Object        $data[' image '] =$_post[' Image ']; $data[' create_time '] = Time(); $list=$model->add ($data); if($list!==false) {             $this->success (' Upload image success! ‘); } Else {             $this->error (' Upload image failed! ')); }     }  }  ?>

thinkphp thumbnail image

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.