Publicfunction Shangchuan () {$ This-display (); } Publicfunction upload () {$uplode=New\think\upload ();//Create an Instantiated object: Create a class that uploads files$uplode->maxsize="31457280";//size of uploaded file$uplode->exts=array ('jpg','gif','PNG','JPEG');//Format Picture$uplode->autosub=true;//automatically use subdirectories to save upload files default to True$uplode->subname=array ('Date','YMD');//file naming method is named after the time stamp of the period$uplode->rootpath="./public/";//represented under the public folder$uplode->savepath="./uploads/";//Set Attachments Upload directory: Indicates that a uploads folder is automatically built under the public folder//Uploading Files$info = $uplodeupload (); if(!$info) { //Upload error message$ This->error ($uplodeGetError ()); }Else{ //upload successfully get upload file information foreach($info as$file) echo $file ['Savepath']. $file ['Savename']; } }
TP Framework for File upload