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 !!