Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that phpcms can't save remote pictures

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to solve the problem that phpcms can't save remote images. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

What if phpcms cannot save remote pictures?

Phpcms v9 can only save remote images of http protocol by default. Of course, you can also set whether or not to save them. I don't know where to set it up. Backend-> content-> Model Management-> Article Model-Field Management-> content Field-modify, as shown below:

Back to the point, there are many websites that enable the https protocol for security, and the images copied from these sites are also https, in which case phpcms cannot automatically save remote images. Just modify the fillurl function in the phpcms/libs/classes/attachment.class.php file, as follows:

/ * complete paramstring$ source address * @ paramstring$absurl relative address * @ paramstring$basehref URL * @ returnstring URL * add localized preservation of images under remote https protocol * / function fillurl ($surl, $absurl, $basehref =') {if ($basehref! ='') {$preurl = strtolower (substr ($surl,0,6)) If ($preurl==' http://' | | $preurl==' https://' | | $preurl==' ftp://' | | $preurl=='mms://' | | $preurl=='rtsp://' | | $preurl=='thunde' | | $preurl=='emule://' | | $preurl=='ed2k://') return $surl;elsereturn $basehref.'/'.$surl;} $I = 0Trachedstr =''; $pstr =''; $okurl =''; $pathStep = 0scape surl = trim ($surl); if ($surl=='') return'; $urls = @ parse_url (SITE_URL) $HomeUrl = $urls ['host']; $BaseUrlPath = $HomeUrl.$urls [' path']; $BaseUrlPath = preg_replace ("/ / ([^\ /] *)\. (. *) $/",'/', $BaseUrlPath); $BaseUrlPath = preg_replace ("/\ / $/",'', $BaseUrlPath); $pos = strpos ($surl,'#'); if ($pos > 0) $surl = substr ($surl,0,$pos); if ($surl [0] = ='/') {$okurl = 'http://'.$HomeUrl.'/'.$surl; } elseif ($surl [0] = ='.') {if (strlen ($surl)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report