Codeigniter framework flash avatar upload and cropping

Source: Internet
Author: User
Tags codeigniter
I recommended an open-source flash Avatar Upload component two days ago. today I added this component to the codeigniter framework. The biggest feature of this component is ease of use. of course, if you want to modify some of the features, you may need to contact the plug-in author for customization.

I recommended an open-source flash Avatar Upload component two days ago. today I added this component to the codeigniter framework. The biggest feature of this component is ease of use. of course, if you want to modify some of the features, you may need to contact the plug-in author for customization.

The following describes how to deploy the flash Avatar Upload component in the codeigniter framework:

1. Controller controllers


// Modify the public function avatar () {$ result = $ this-> userinfo_model-> get_user_base_info_by_uid ($ this-> uid); $ data = array (); $ data ['Avatar '] = $ this-> default_avatar; if ($ result [0]-> avatar! = '') {$ Data ['Avatar '] = base_url (). "uploads/users/avatar/{$ this-> uid}/{$ this-> uid1__big.png" ;}$ this-> view ('userinfo/avatar ', $ data);} // public function doavatar () {error_reporting (0); // Set the Avatar storage directory $ webroot = $ _ SERVER ['document _ root']; $ save_path = "{$ webroot}/uploads/users/avatar/{$ this-> uid}/"; if (! File_exists ($ save_path) {mkdir ($ save_path, 0777, true);} $ file_src = "src.png "; $ filename162 = "{$ save_path} {$ this-> uid1__big.png"; $ filename48 = "{$ save_path} {$ this-> uid1__middle.png "; $ filename20 = "{$ save_path} {$ this-> uid1__small.png"; $ src = base64_decode ($ _ POST ['Pic ']); $ pic1 = base64_decode ($ _ POST ['pic1']); $ pic2 = base64_decode ($ _ POST ['pic2']); $ pic3 = base64_decode ($ _ POST ['pic3']); if ($ src) {file_put_contents ($ file_src, $ src);} file_put_contents ($ filename162, $ pic1 ); file_put_contents ($ filename48, $ pic2); file_put_contents ($ filename20, $ pic3); $ data = array (); $ data ['Avatar '] = $ this-> uid; $ result = $ this-> userinfo_model-> update_user_by_uid ($ this-> uid, $ data); if ($ result) {$ rs ['status'] = 1; echo json_encode ($ rs );}}

2. View views



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.