The solution to the problem that php downloads pictures can't be opened.
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!