一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

phpcms实现不同站点图片上传到不同文件夹

时间:2022-06-25 16:26:07 编辑:袖梨 来源:一聚教程网

1.修改配置文件system.php

 代码如下 复制代码

//附件相关配置
'upload_path' => PHPCMS_PATH.'upload/',
'upload_path_danji' => PHPCMS_PATH.'danji/upload/',//单机站图片上传路径
'upload_path_mobile' => PHPCMS_PATH.'upload/shouji/',//手机站图片上传路径
'upload_url' => '/upload/', //附件路径
'upload_url_danji' => '/danji/upload/',//单机站附件路径
'upload_url_mobile' => '/upload/shouji/', //手机站附件路径

2.在文件夹中搜索“upload_path”
在文件夹中搜索“upload_path”,可以找到多出文件使用了这个配置参数,这里就是要修改的地方,根据当前站点进行判断。
比如modules/attachment/attachments.php

 代码如下 复制代码
function __construct() {
 pc_base::load_app_func('global');
 $this->siteid = param::get_cookie('siteid');
 if ($this->siteid == 1) {
  $this->upload_url = pc_base::load_config('system','upload_url');
  $this->upload_path = pc_base::load_config('system','upload_path');
 } elseif ($this->siteid == 2) {
  $this->upload_url = pc_base::load_config('system','upload_url_danji');
  $this->upload_path = pc_base::load_config('system','upload_path_danji');
 } elseif ($this->siteid == 3) {
  $this->upload_url = pc_base::load_config('system','upload_url_mobile');
  $this->upload_path = pc_base::load_config('system','upload_path_mobile');
 }
 
 $this->imgext = array('jpg','gif','png','bmp','jpeg');
 $this->userid = param::get_cookie('userid') ? param::get_cookie('userid') : param::get_cookie('_userid');
 $this->isadmin = $this->admin_username = $_SESSION['roleid'] ? 1 : 0;
 $this->groupid = param::get_cookie('_groupid') ? param::get_cookie('_groupid') : 8;
}

对构造函数进行修改,根据当前站点,读取对应的upload_path参数和路径参数。有几处地方都如此修改,就不一一列举了。

热门栏目