Phpcms front Page Upload file

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.