Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of uploading files on phpcms

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report