phpcms怎么上传文件

(图1)

phpcms怎么上传文件?phpcms前端页面上传文件

PHPCMS其实有一个叫做附件的模块,上传用的就是这个东西,现在我们来看一下对应的文件:phpcmsmodulesattachment attachments.php就是这个文件,大概在29行上(我用的PHPCMS版本号是Phpcms V9.5.8 Release 20140929)有下面一个方法:

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,''); } }

以上应该解释的比较详细了,不懂的话可以自己看一下对应的文件,好了现在我们来看前端:

这个就是上传用的~注意调用的action的路径就好了~再就是这里的的name属性必须为upload否则无法上传成功,因为在attachment类中定死了上传的name属性,所以 这里只能用这个了~

PHP中文网,大量的免费PHPCMS教程,欢迎在线学习!

以上就是phpcms怎么上传文件的详细内容,更多请关注其它相关文章!

1、本站目前拥有近 1000+ 精品收费资源,现在加入VIP会员即可全部下载。
2、本资源部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
SEA模板网 » phpcms怎么上传文件

发表评论

加入本站VIP会员订阅计划,海量资源免费查看

目前为止共有 3654 位优秀的VIP会员加入! 立刻加入VIP会员