Home > CMS Tutorial > PHPCMS > body text

How to upload files in phpcms

藏色散人
Release: 2019-12-26 11:25:08
Original
3000 people have browsed it

How to upload files in phpcms

How to upload files in phpcms? Upload files on the phpcms front-end page

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

public function upload() { $grouplist = getcache('grouplist','member');   //获取缓存中身份分组的列表
        if($this->isadmin==0 && !$grouplist[$this->groupid]['allowattachment']) return false;   //判断是否允许上传附件
        pc_base::load_sys_class('attachment','',0);   //加载attachment类
        $module = trim($_GET['module']);  //通过get方式获取模型
        $catid = intval($_GET['catid']);  //通过get方式获取catid
        $siteid = $this->get_siteid();   //获取站点ID
        $site_setting = get_site_setting($siteid);   //获取站点配置信息,这个函数在此模块中的公共函数global.func.php中可以找到
        $site_allowext = $site_setting['upload_allowext'];  //获取到允许的上传文件类型 
        $attachment = new attachment($module,$catid,$siteid);   //实例化attachment类,就是上面刚刚提到的加载进来的类
        $attachment->set_userid($this->userid);  //调用attachment类的set_userid函数,确定是哪个用户上传的。
        $a = $attachment->upload('upload',$site_allowext);  //上传文件,具体的函数请查看attachment类。
        if($a){     //下面这些就是上传成功后的一些路径和文件名什么的了~
            $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,''); } }
Copy after login

The above should be explained in more detail. If you don’t understand, you can read the corresponding one yourself. file, okay, now let’s 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>
Copy after login

This is for uploading~ Just pay attention to the path of the called action~ Then here’s

PHP Chinese website, a lot of freePHPCMS Tutorial , welcome to learn online!

The above is the detailed content of How to upload files in phpcms. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!