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

The solution to the problem that php downloads pictures can't be opened.

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains the "php download picture can not open the solution", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn the "php download picture can not open the solution" bar!

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What if the php download picture cannot be opened?

Resolve the problem that the PHP curl or file_get_contents downloaded picture is damaged or cannot be opened

Capture remote images through curl or file_get_contents and save them locally. It is found that many images are damaged, such as visiting

Https://fuss10.elemecdn.com/c/6c/69a7740b4ab864ac0639eb583d68fjpeg.jpeg

The picture can be accessed, but it is corrupted when the picture is downloaded in curl or file_get_contents.

Something like this:

The reason is that the picture has been gizp

Solution 1:

$url = 'https://fuss10.elemecdn.com/c/6c/69a7740b4ab864ac0639eb583d68fjpeg.jpeg'; $img = file_get_contents ("compress.zlib://". $url); $data = file_put_contents.

Solution 2:

Add this code to curl

Curl_setopt ($ci, CURLOPT_ENCODING,'gzip'); thank you for reading, the above is the "php download pictures can not open the solution" of the content, after the study of this article, I believe that you can not open the php download pictures of the solution to this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Development

Wechat

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

12
Report