Today thanks to the netizen guidance, only to understand how to upload files at the front desk, recorded to share with you
Phpcms actually have a module called attachment, upload is this thing, now let's 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 function upload () {$grouplist = GetCache (' grouplist ', ' member '); Gets the list of identity groupings in the cache if ($this->isadmin==0 &&! $grouplist [$this->groupid][' allowattachment ']) return false; Determine whether to allow uploading of attachments pc_base::load_sys_class (' attachment ', ', 0); Load Attachment class $module = Trim ($_get[' module '); Get model $catid = intval ($_get[' catid ') by get mode; Get Catid$siteid = $this->get_siteid () by Get method; Get site id$site_setting = get_site_setting ($siteid); Get Site configuration information, this function 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 type $ Attachment = new Attachment ($module, $catid, $siteid); Instantiate the attachment class, which is the loaded class $attachment->set_userid ($this->userid) just mentioned above; 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) {//The following 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 "> <input type=" file "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 ~
Phpcms front Page Upload file