主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情! |
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作 |
phpcms不能保存远程图片怎么办?
默认情况下,phpcms v9只能保存http协议的远程图像。当然,您也可以设置是否自己保存它们。我不知道把它放在哪里。后台-》内容-》模型管理-》文章模型-》字段管理-》内容字段-修改,如下图:
反正很多网站为了安全都启用了https协议,从这些网站复制的图片也是https。在这种情况下,phpcms无法自动保存远程图片。只需修改phpcms/libs/classes/attachment . class . PHP文件中的fillurl函数,如下所示:
/* * *完成URL ** @paramstring$surl源地址* @paramstring$absurl相对地址* @ paramstring $ base href URL * @ return string URL *增加远程https协议下图片的本地化保存*/函数填充URL($ surl,$absurl,$ base href = &;#39;& amp#39;){ if($ base href!= & amp#39;& amp#39;){ $ preurl = strtower(substr($ surl,0,6));if($ preurl = = & amp;#39;http://& amp;#39;| | $ preurl = = & amp#39;https://& amp;#39;| | $ preurl = = & amp#39;FTP://& amp;#39;| | $ preurl = = & amp#39;彩信://& amp;#39;| | $ preurl = = & amp#39;RTSP://& amp;#39;| | $ preurl = = & amp#39;图恩德& amp#39;| | $ preurl = = & amp#39;emule://& amp;#39;| | $ preurl = = & amp#39;ed2k://& amp;#39;)返回$ surlelsereturn $basehref。& amp#39;/& amp;#39;。$ surl} $ I = 0;$ dstr = & amp#39;& amp#39;;$ pstr = & amp#39;& amp#39;;$ okurl = & amp#39;& amp#39;;$ path step = 0;$ surl = trim($ surl);if($ surl = = & amp;#39;& amp#39;)返回& amp#39;& amp#39;;$ URLs = @ parse _ URL(SITE _ URL);$ HomeUrl = $ URLs【& amp;#39;主持人&。#39;];$BaseUrlPath = $HomeUrl。$ URLs【& amp;#39;路径与方法。#39;];$ base URL path = preg _ replace(& quot;/\/([^\/]*)\.(.*)$/& quot;,& amp#39;/& amp;#39;,$ base URL path);$ base URL path = preg _ replace(& quot;/\/$/& quot;,& amp#39;& amp#39;,$ base URL path);$ pos = strpos($ surl,& amp#39;# & amp#39;);if($ pos & gt;0)$ surl = substr($ surl,0,$ pos);if($ surl【0】= = & amp;#39;/& amp;#39;){ $ okurl = & amp#39;http://& amp;#39;。$HomeUrl。& amp#39;/& amp;#39;。$ surl} else if($ surl【0】= = & amp;#39;。& amp#39;){ if(strlen($ surl)& lt;=2)返回& amp#39;& amp#39;;else if($ surl【0】= = & amp;#39;/& amp;#39;){ $ okurl = & amp#39;http://& amp;#39;。$BaseUrlPath。& amp#39;/& amp;#39;。substr($ surl,2,strlen($ surl)-2);} else { $ URLs = explode(& amp;#39;/& amp;#39;,$ surl);foreach($ URLs as $ u){ if($ u = = & quot;..")$ path step++;else if($ I & lt;count(URL)-1)$ dstr。= $ URLs【$ I】。& amp#39;/& amp;#39;;else $dstr。= $ URLs【$ I】;$ i++;} $ URLs = explode(& amp;#39;/& amp;#39;,$ base URL path);if(count(URL)& lt;= $ pathStep)return & amp;#39;& amp#39;;else { $ pstr = & amp#39;http://& amp;#39;;for($ I = 0;$ i & ltcount($ URLs)-$ path step;$ i++){ $ pstr。= $ URLs【$ I】。& amp#39;/& amp;#39;;}$okurl = $pstr。$ dstr} } } else { $ preurl = strtolow(substr($ surl,0,6));if(strlen(surl)& lt;7)$ okurl = & amp;#39;http://& amp;#39;。$BaseUrlPath。& amp#39;/& amp;#39;。$ surlelse if($ preurl = = & quot;http:/& quot;| | $ preurl = = & quothttps:& quot;| | $ preurl = = & amp#39;FTP://& amp;#39;| | $ preurl = = & amp#39;彩信://& amp;#39;| | $ preurl = = & quotRTSP://& quot;| | $ preurl = = & amp#39;图恩德& amp#39;| | $ preurl = = & amp#39;电驴:& amp#39;| | $ preurl = = & amp#39;ed2k:/& amp;#39;)$ okurl = $ surlelse $ okurl = & amp#39;http://& amp;#39;。$BaseUrlPath。& amp#39;/& amp;#39;。$ surl} $ preurl = strtower(substr($ okurl,0,6);if($ preurl = = & amp;#39;FTP://& amp;#39;| | $ preurl = = & amp#39;彩信://& amp;#39;| | $ preurl = = & amp#39;RTSP://& amp;#39;| | $ preurl = = & amp#39;图恩德& amp#39;| | $ preurl = = & amp#39;电驴:& amp#39;| | $ preurl = = & amp#39;ed2k:/& amp;#39;){ return $ okurl} else { $ okurl = preg _ replace(& amp;#39;/^(http:\/\/)/i&;#39;,& amp#39;& amp#39;,$ okurl);$ okurl = preg _ replace(& amp;#39;/^(https:\/\/)/i&;#39;,& amp#39;& amp#39;,$ okurl);$ okurl = preg _ replace(& amp;#39;/\/{1 ,}/I & amp;#39;,& amp#39;/& amp;#39;,$ okurl);退货和退货。#39;http://& amp;#39;。$ okurl}}其中,https是新的,但它最初并不存在。
PHP中文网站,大量免费PHPCMS教程,欢迎在线学习!
这几篇文章你可能也喜欢:
- PHPCMS漏洞文件poster.php(php readfile漏洞)
- phpcms有什么用(如何使用phpcms)
- phpcms如何登录后台?
- 如何将phpcms连接到数据库(phpcms使用教程)
- 如何向phpcms添加列(php添加页面)
本文由主机参考刊发,转载请注明:phpcms不能保存远程图片怎么办? https://zhujicankao.com/114121.html
评论前必须登录!
注册