织梦DEDECMS改图片域名显示

1.需要在织梦->系统->系统基本参数->添加新变量

这里写图片描述
是否开启图片域名 1开启 0关闭
cfg_oss_imagesed 1

图片域名路径
cfg_oss_images_host http://s1.hgcang.com/bsimg

2.修改把图片上传到ftp

路径:cms/include/dialog/select_images_post.php line:64

从原有的

if($cfg_remote_site=='Y' && $remoteuploads == 1)
{
    //分析远程文件路径
    $remotefile = str_replace(DEDEROOT, '', $fullfilename);
    $localfile = '../..'.$remotefile;
    //创建远程文件夹
    $remotedir = preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/', '', $remotefile);
    $ftp->rmkdir($remotedir);
    $ftp->upload($localfile, $remotefile);
}

改为

if($cfg_oss_imagesed) {
    require_once(DEDEINC . '/ftp.class.php');
    if (file_exists(DEDEDATA . "/cache/inc_remote_config.php")) {
        require_once DEDEDATA . "/cache/inc_remote_config.php";
    }
    if (empty($remoteuploads)) $remoteuploads = 0;
    if (empty($remoteupUrl)) $remoteupUrl = '';
    $config = array(
        'hostname' => $GLOBALS['cfg_ftp_host'],
        'username' => $GLOBALS['cfg_ftp_user'],
        'password' => $GLOBALS['cfg_ftp_pwd'],
        'passive'  => 'TRUE',
        'debug'    => 'TRUE'
    );
    $ftp = new FTP($config);
    $ftp->connect();
//分析远程文件路径
    $remotefile = str_replace(DEDEROOT, '', $fullfilename);
    $localfile = '../..' . $remotefile;
//创建远程文件夹
    $remotedir = preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/', '', $remotefile);
    $ftp->rmkdir($remotedir);
    $ftp->upload($localfile, $remotefile);
    @unlink($localfile);
} else {
    /**************/
    if($cfg_remote_site=='Y' && $remoteuploads == 1)
    {
    //分析远程文件路径
    $remotefile = str_replace(DEDEROOT, '', $fullfilename);
    $localfile = '../..'.$remotefile;
    //创建远程文件夹
    $remotedir = preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/', '', $remotefile);
    $ftp->rmkdir($remotedir);
    $ftp->upload($localfile, $remotefile);

    }
}

3.修改显示图片路径

路径:cms/include/dialog/select_images_post.php line:108
从原有的

$fileurl = $activepath.'/'.$filename;

改为

$fileurl = ($cfg_oss_imagesed ? $cfg_oss_images_host : '') . '/' . ltrim($activepath , '/') .'/'.$filename;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值