Thinkphp_ Image upload cropping function

Source: Internet
Author: User

Preparation materials

    1. thinkphp

    2. jquery Form Plug-in

    3. Cropper cropping plug-in


Ideas: Using thinkphp Upload file class and picture cutting class, the front desk to find ways to combine parameters to the backstage how can you commit files asynchronously? The key is the jquery form plugin.


Background preparation

Thinkphp Upload class http://www.kancloud.cn/manual/thinkphp/1876

Thinkphp Clipping class http://www.kancloud.cn/manual/thinkphp/1878


Front Desk Preparation

jquery form plug-in http://malsup.com/jquery/form/#code-samples Chinese document http://www.cnblogs.com/linzheng/archive/2010/11/17/ 1880288.html

Crop plugin http://www.jqcool.net/image-cropper.html

Instant preview of images (no uploading of files)

/** *  get   Local picture  url */ function getfileurl (SourceID)  {from  file  domain  var url; if  (Navigator.userAgent.indexOf ("MSIE") >=1)  { // ie url  = document.getelementbyid (SourceID). Value; } else if (Navigator.userAgent.indexOf (" Firefox ") >0)  { // firefox url = window. Url.createobjecturl (document.getElementById (SourceID). Files.item (0));  } else if ( Navigator.userAgent.indexOf ("Chrome") >0)  { // chrome url = window. Url.createobjecturl (document.getElementById (SourceID). Files.item (0));  } return url; }  /** *  display local picture   to browser  */ function preimg (Sourceid, targetid)  {  var url = getfileurl (SourceID);  var imgpre = document.getelementbyid ( Targetid);  imgpre.src = url; } //Trigger event Call  preimg (This.id, ' IMgpre '); 

Thinkphp_ picture upload cropping feature

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.