Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of uploading files on phpcms

Shulou Source: shulou.com Published: 2022-06-02 04:48:56 09月20日 Update

How to upload files on phpcms? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

How does phpcms upload files? Phpcms front-end page uploads files

PHPCMS actually has a module called attachment, which is used for uploading. Now let's take a look at the corresponding file: phpcms\ modules\ attachment\ attachments.php. There is probably a method on line 29 (the PHPCMS version I use is Phpcms V9.5.8 Release 20140929):

Public function upload () {$grouplist = getcache ('grouplist','member'); / / get the list of identity groups in the cache if ($this- > isadmin==0 & &! $grouplist [$this- > groupid] [' allowattachment']) return false; / / determine whether the attachment pc_base::load_sys_class ('attachment','',0) is allowed; / / load the attachment class $module = trim ($_ GET [' module']) / / get the model $catid = intval ($_ GET ['catid']) by get; / / get catid $siteid = $this- > get_siteid () by get; / / get the site ID $site_setting = get_site_setting ($siteid) / / get site configuration information. This function can find $site_allowext = $site_setting ['upload_allowext'] in the common function global.func.php in this module; / / get 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); / / upload files. For specific functions, please see the attachment class. If ($a) {/ / these are some paths and file names after a 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. If you don't understand, you can take a look at the corresponding file for yourself. OK, now let's look at the front end:

This is for uploading ~ just pay attention to the path of the called action ~ again, the name attribute here must be upload or it cannot be uploaded successfully, because the uploaded name attribute is fixed in the attachment class, so this can only be used here.

Thank you for reading! After reading the above, do you have a general understanding of the method of uploading files on phpcms? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Tags: Files that is contents functions methods success front ends properties articles methods modules sites paths problems attachments things information instances file names more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker Shulou Tech Info Microsoft Apple