"그렇습니다."/> "그렇습니다.">

 >  기사  >  CMS 튜토리얼  >  phpcms에서 파일을 업로드하는 방법

phpcms에서 파일을 업로드하는 방법

藏色散人
藏色散人원래의
2019-12-26 11:25:082928검색

phpcms에서 파일을 업로드하는 방법

phpcms 파일을 업로드하는 방법은 무엇인가요? phpcms 프런트엔드 페이지에 파일 업로드

PHPCMS에는 실제로 업로드에 사용되는 attachments라는 모듈이 있습니다. 이제 해당 파일을 살펴보겠습니다. phpcmsmodulesattachment attachments.php는 다음과 같습니다. 이 파일의 29번째 줄(내가 사용하는 PHPCMS 버전 번호는 Phpcms V9.5.8 릴리스 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,''); } }

그렇지 않은 경우 위의 내용을 더 자세히 설명해야 합니다. 이해가 안 되시면 직접 파일을 보시면 됩니다. 이제 프론트엔드를 살펴보겠습니다:

<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>

업로드용입니다~ 호출된 액션의 경로만 주의하세요~ 그러면 여기에 41fd4ca2d23b545db6db92450b4a629b의 name 속성이 반드시 업로드되어야 합니다. 그렇지 않으면 업로드된 이름 속성이 첨부 파일 클래스에 고정되어 있으므로 여기서만 사용할 수 있으므로 업로드가 성공할 수 없습니다~# 🎜🎜#

PHP 중국어 웹사이트, 많은 무료

PHPCMStutorial, 온라인 학습을 환영합니다!

위 내용은 phpcms에서 파일을 업로드하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.