dedecms采集的时候自动把图片上传到又拍云


打开dede/co_export.php找到37行在require_once(DEDEINC.'/dedecollection.class.php');下面判断时候开启了又拍云

/*
 *是否开启又拍云
 *导入unyun.class
 */

if (($cfg_open_upyun == 'Y') && $cfg_upyun_username && $cfg_upyun_spacename && $cfg_upyun_password ) {
	include DEDEADMIN.'/inc/UpYun.class.php';
	$upyun	=	new UpYun($cfg_upyun_spacename, $cfg_upyun_username, $cfg_upyun_password);
	$openUpYun = true;
} else {
	$openUpYun = false;;	
}
$cfg_open_upyun开关,我在后台添加了一个boolean类型的变量

$cfg_upyun_username 又拍用户名

$cfg_upyun_spacename 空间名

$cfg_upyun_password密码


然后找到247行 $addSql = str_replace("@$itemname@", $itemvalue, $addSql);在下面增加如下代码

//开启又拍云存储
			if($openUpYun) {
				$values	=	$ctag->GetInnerText();
				if($itemname == 'litpic') {
					try {
						$fh		=	fopen('../..'.$values, 'rb');
						$rsp	=	$upyun->writeFile('/'.$litpic, $fh, True);   // 上传图片,自动创建目录
						fclose($fh);
					} catch(Exception $e) {
						echo $e->getCode();
						echo $e->getMessage();
						exit;
					}
				}
				if($itemname == 'imgurls') {
					$dtp = new DedeTagParse();
					$dtp->LoadSource(stripslashes($values));
					if(is_array($dtp->CTags)) {
						foreach($dtp->CTags as $ctag) {
							if($ctag->GetName()=="img") {
								$bigimg = trim($ctag->GetInnerText());
								if($ctag->GetAtt('ddimg') != $bigimg && $ctag->GetAtt('ddimg')!='') {
									$litimg = $ctag->GetAtt('ddimg');
								} else {
									$litimg = $bigimg;
								}
								try {
									$fh		=	fopen('../..'.$litimg, 'rb');
									$rsp	=	$upyun->writeFile($litimg, $fh, True);   // 上传图片,自动创建目录
									fclose($fh);
								} catch(Exception $e) {
									echo $e->getCode();
									echo $e->getMessage();
									exit;
								}
							}
						}
					}
					$dtp->Clear();
				}
			}
fopen里面的路径需要根据实际情况修改下。


以上就是采集完成导出内容的时候把图片附件上传到又拍云上面。写的不好,请见谅。如有更好的解决方式请告知谢谢!sobeautiy@126.com


太囧笑话网

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值