zhoji 发表于 2020-5-1 23:30:33

discuz:远程附件与本地附件的之间的转换教程



最近本人因为想把阿里云OSS的远程附件搬到自己本地服务器上。最后图片啥的都搬回来准备妥当了,然而帖子图片却打不开了,显示的还是远程地址,最后去网上搜了下原因,才知道还要执行数据库升级,下面是操作教程!


第一步,使用FTP把本地 /data/attachment/ 目录下的文件下载到本地,这里我只用到了文件目录下的/forum,/portal和/block
https://www.piliw.cn/data/attachment/forum/202004/12/203821shg7xbvghgwxx1wh.png.thumb.jpg
第二步,FTP登录远程服务器。分别把下载下来的三个文件夹里的上传到远程服务器对应的目录里。

https://www.piliw.cn/data/attachment/forum/202004/12/203821ds0hvjv2zasvvaha.png.thumb.jpg
第三步,数据库执行sql语句,



论坛的:(0表示本地,1表示远程)
update pre_forum_attachment_1 set remote=1 where remote=0; update pre_forum_attachment_2 set remote=1 where remote=0; update pre_forum_attachment_3 set remote=1 where remote=0; update pre_forum_attachment_4 set remote=1 where remote=0; update pre_forum_attachment_5 set remote=1 where remote=0; update pre_forum_attachment_6 set remote=1 where remote=0; update pre_forum_attachment_7 set remote=1 where remote=0; update pre_forum_attachment_8 set remote=1 where remote=0; update pre_forum_attachment_9 set remote=1 where remote=0;门户的:
update pre_portal_article_title set remote=1 where remote=0; update pre_portal_attachment set remote=1 where remote=0; update pre_portal_topic_pic set remote=1 where remote=0;进入论坛后台,依次点击:站长-数据库-升级


https://www.piliw.cn/data/attachment/forum/202004/12/204049xzhldagk6g9121k1.png.thumb.jpg
把数据库升级语句复制到箭头方向,点击升级。(最好备份一下数据库)

之后更新网站缓存,进入网站随便点开一个之前附件在本地的帖子。邮件附件复制链接,如果链接地址和后台设置的远程访问 URL一致,表示迁移成功,就可以把本地的对应目录下的文件删除了。

之后更新网站缓存,进入网站随便点开一个之前附件在本地的帖子。邮件附件复制链接,如果链接地址和后台设置的远程访问 URL一致,表示迁移成功,就可以把本地的对应目录下的文件删除了。



https://www.piliw.cn/static/image/hrline/1.gif
以上是本地附件转换成远程附件的方法!如果以后不用远程附件了!只要反着操作就行了,比如数据库执行sql语句
update pre_forum_attachment_1 set remote=0 where remote=1; update pre_forum_attachment_2 set remote=0 where remote=1; update pre_forum_attachment_3 set remote=0 where remote=1; update pre_forum_attachment_4 set remote=0 where remote=1; update pre_forum_attachment_5 set remote=0 where remote=1; update pre_forum_attachment_6 set remote=0 where remote=1; update pre_forum_attachment_7 set remote=0 where remote=1; update pre_forum_attachment_8 set remote=0 where remote=1; update pre_forum_attachment_9 set remote=0 where remote=1;update pre_portal_article_title set remote=0 where remote=1; update pre_portal_attachment set remote=0 where remote=1; update pre_portal_topic_pic set remote=0 where remote=1;把0和1对掉下就OK了!很简单吧,记得收藏备用哟.


页: [1]
查看完整版本: discuz:远程附件与本地附件的之间的转换教程