Thinkphp corrected Avatar

Source: Internet
Author: User
Thinkphp changes the Avatar foreground & lt; formaction = & quot ;__ URL _/user_upimgs & quot; method = & quot; post & quot; enctype = & quot; multipart/form-data & quot; & gt; & nbsp; & nb thinkphp modify the Avatar

Front-end




Background

Function user_upimgs (){

Import ("ORG. Net. UploadFile ");

$ Upload = new UploadFile (); // instantiate the upload class

$ Upload-> maxSize = 3145728; // sets the attachment upload size.
$ Upload-> allowExts = array ('jpg ', 'GIF', 'PNG', 'jpeg '); // you can specify the attachment upload type.

$ Upload-> saveRule = uniqid ;//

$ Upload-> savePath = './Public/Uploads/'; // sets the attachment upload Directory

If (! $ Upload-> upload () {// upload error message

$ This-> error ($ upload-> getErrorMsg ());

} Else {// the uploaded file is successfully obtained.

$ Info = $ upload-> getUploadFileInfo ();

}

// Save the form data, including the attachment data

$ User = M ("users"); // instantiate the User object

$ User-> create (); // create a data object

$ User-> user_upimg = 'uploads/'. $ info [0] ["savename"]; // Save the uploaded photo and assemble it as needed

// $ User-> fenxiang_ SC = 'uploads/'. $ info2 [0] ["savename"];
$ Imgs = D (); // write user data to the database
$ Imgs-> query ("update users set user_upimg = 'uploads /". $ info [0] ["savename"]. "'Where users_id = '". $ _ POST ['users _ id']. "'");
$ This-> success ("data is saved successfully! ");


}

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.