A pitfall in obtaining remote images with PHP

不言
Release: 2023-03-24 15:34:02
Original
1792 people have browsed it

The content of this article is about a pitfall in obtaining remote images with PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it

https://steamcdn-a .akamaihd.net/steamcommunity/public/images/avatars/3b/3b7a04c0bb38aa354bba8086871c91050a5f2170_full.jpg. This is a remote image. You can type it directly in the URL address bar. When obtaining this image, file_get_contents and curl are both used. But it doesn’t work, I just can’t get it. The specific reason is not clear, but it works better if I change https to http. Just change the above link to http://steamcdn-a.akamaihd.net/steamcommunity/public/ images/avatars/3b/3b7a04c0bb38aa354bba8086871c91050a5f2170_full.jpg, you can get this picture. There is a lot of information on the Internet about the difference between http and https, but I can’t understand it. Generally speaking, https is the safe version of HTTP. When you live or die, You can think about this when you can't get it. There is also information on the Internet, and some solutions are at:

http://blog.csdn.net/terry_water/article/details/39377255 http://blog.csdn. net/gdali/article/details/52227601 http://www.jb51.net/article/44524.htm

http://www.jb51.net/article/72552.htm

http://blog.csdn.net/terry_water/article/details/39377255

But I think the easiest thing is to change https in the path to http. How to change it? explode(‘:’,$url), then change https to http and then splice them together, that’s it.




The above is the detailed content of A pitfall in obtaining remote images with PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!