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

来源:互联网 发布:win7网络共享访问权限 编辑:程序博客网 时间:2024/04/28 08:02


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


太囧笑话网

原创粉丝点击