ThinkPHP learning notes (14) The Action settings are required for uploading files, including the file introduction of UploadFile & lt ;? Php/*** file Upload processing function ** @ authoradmin **: when uploading multiple files, you can add [] ThinkPHP learning notes (14th) to the name in the input file to upload files.
Action settings are required, including file introduction of UploadFile.
Select (); $ this-> assign ('alist', $ list); $ this-> display ();} function upload () {// custom model if (empty ($ _ FILES) {$ this-> error ("file upload required ");} else {$ msg = $ this-> up (); if (isset ($ msg) {$ result = $ this-> insertDb ($ msg); if ($ result) {$ this-> success ('uploaded successfully');} else {$ this-> error ('failed to save that ');}} else {$ this-> error ($ msg) ;}} private function insertDb ($ data) {$ file = M ('file'); $ result = true; for ($ I = 0; $ I <count ($ data); $ I ++) {$ data ['Filename'] = $ data [$ I] ['savename']; if (! $ File-> data ($ data)-> add () {return false ;}} return true;} private function up () {import ('org. net. uploadFile '); $ upload = new UploadFile (); $ upload-> maxSize = '000000'; // The size is-1; the unit is bytes $ upload-> savePath = '. /Public/'; // upload path: We recommend that you use a subdirectory of the main intersection or level directory to $ upload-> saveRule = 'uniqid'; // Save the rule: the default value is uniqid $ upload-> hashType = 'md5'; // hash verification method. the default value is MD5 $ upload-> autoCheck = false; $ upload-> uploadReplace = true; $ upload-> allowExts = array ('jpg ', 'p Ng '); // The format of the file to be uploaded $ upload-> allowTypes = array ('image/png', 'image/jpg '); // mime type of the file $ upload-> thumb = true; // whether to enable the image file thumbnail $ upload-> thumbMaxWidth = '000000'; // you can use, split, write multiple maximum widths $ upload-> thumbMaxHeight = '000000'; // corresponds to the width one by one $ upload-> thumbPrefix ='s _, m _'; // prefix of the thumbnail file, one-to-one correspondence with width // $ upload-> thumbPath = ''; // save path of the thumbnail, if it is null, directly upload the file to $ upload-> savePath // $ upload-> thumbFile = ''; // The name of the thumbnail file is generally not used, you can directly use the prefix $ upload-> thumbRemoveOrigin = 1; // generate a new graph. Whether to delete the source image // $ upload-> autoSub = false; // whether to use sub-directories for saving // $ upload-> subType = ''; // How to create sub-directories, by default, it is created for hash. you can also set it to date // $ upload-> dateFormat = ''; // specify the format of date in the subdirectory // $ upload-> hashLevel = ''; // hash level if ($ upload-> upload () {$ msg = $ upload-> getUploadFileInfo (); dump ($ msg); return $ msg ;} else {$ this-> error ($ upload-> getErrorMsg (); return $ upload-> getErrorMsg () ;}}?>
Html
<!--{$title}-->
"/>"/>