Thinkphp image upload class tp3.0 file Upload class

Source: Internet
Author: User
Stores a thinkphp file Upload class. Very powerful Upload class! Thinkphp image upload class tp3.0 file Upload class favorites a thinkphp file Upload class. Very powerful Upload class! Thinkphp image upload class tp3.0 file Upload class
Public function upload () {import ("ORG. net. uploadFile "); $ upload = new UploadFile (); // you can specify the size of the uploaded file. $ upload-> maxsize = 3145728; // Set the upload file type $ upload-> allowExts = explode (',', "jpg, gif, jpeg, png "); // set the nearby upload directory $ upload-> savePath = ". /Upload/zpimg/"; // note that the directory is the relative path of the file to be imported. // you need to generate a thumbnail, which is only valid for image files. // $ upload-> thumb = true; // set the path of the referenced image library package // $ upload-> imageClassPath = 'org. net. image'; // specifies the file suffix of the thumbnail to be generated. // $ upload-> thumbPrefi X ='m _, s _ '; // Generate two thumbnails. // set the maximum width of the thumbnail. // $ upload-> thumbMaxWidth = '000000 '; // set the maximum height of the thumbnail // $ upload-> thumbMaxHeight = '000000'; // Set the upload file rule $ upload-> saveRule = uniqid; // delete the source image $ upload-> thumbRemoveOrigin = true; if (! $ Upload-> upload () {// capture upload exceptions $ this-> error ($ upload-> getErrorMsg ());} else {// get the information of the uploaded file $ info = $ upload-> getUploadFileInfo (); // $ this-> success ("uploaded successfully");} return $ info ;}

Here is one of my call classes for sharing. here are two images for Uploading:

if($_FILES['photo']['size']>0){$file_name = $this->upload();$data['list_photo'] = $file_name[0]['savename'];$data['photo2'] = $file_name[1]['savename'];}

Put all the variables in $ data. It can be inserted or modified !!

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.