Phpcms actually have a module called attachment, upload is this thing, now we look at the corresponding file: phpcms\modules\attachment \ attachments.php is this file, probably on line 29 (I use the PHPCMS version number is phpcms V9.5.8 release 20140929) has the following method:
Public functionupload () {$grouplist= GetCache (' grouplist ', ' member ');//get a list of identity groupings in the cache if($this->isadmin==0 &&!$grouplist[$this->groupid][' allowattachment ')return false;//determine if attachments are allowed to be uploadedPc_base::load_sys_class (' attachment ', ', 0);//load Attachment class $module=Trim($_get[' module ']);//get the model by get mode $catid=intval($_get[' catid ']);//get catid by Get method $siteid=$this->get_siteid ();//Get Site ID $site _setting= Get_site_setting ($siteid);//Gets the site configuration information, which can be found in the public function global.func.php in this module $site _allowext=$site _setting[' Upload_allowext '];//get to the allowed upload file types $attachment=NewAttachment$module,$catid,$siteid);//instantiate the attachment class, which is the loaded class just mentioned above $attachment->set_userid ($this->userid);//Call the Set_userid function of the attachment class to determine which user uploaded it. $a=$attachment->upload (' Upload ',$site _allowext);//to upload a file, see the attachment class for specific functions. if($a){//Here are some of the paths and filenames after the successful upload ~ $filepath=$attachment->uploadedfiles[0][' filepath ']; $FN=intval($_get[' Ckeditorfuncnum ']); $this->upload_json ($a[0],$filepath,$attachment->uploadedfiles[0][' filename ']); $attachment->mkhtml ($FN,$this->upload_url.$filepath,‘‘); } }
The above should be explained in more detail, do not understand the words can see the corresponding documents, well now we look at the front end:
<form method= "POST" enctype= "Multipart/form-data" action= "/index.php?m=attachment&c=attachments&a= Upload "id=" uploadload "target=" Iframelogo "> class=" Uploadtxt "name=" upload "/><input type=" Submit "value=" Dianji "/></form>
This is the upload use ~ Note the path of the action call is good ~ then here's <input type=file name= "Upload" > the Name property must be upload otherwise cannot upload success, Because the uploaded name attribute is dead in the attachment class, this is the only place to use it ~
Reprint: http://www.cnblogs.com/woshikay/p/4329912.html
Phpcms front Page Upload file