开发者

download gzip file via php cURL

开发者 https://www.devze.com 2023-02-06 00:17 出处:网络
I want to download file and save it. I am using this code for downloading gzip file. $ch = curl_init();

I want to download file and save it. I am using this code for downloading gzip file.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_params['url']);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true);
$post = array("image_id"=>开发者_如何学Go;  $this->_response_id, "format"=>$this->_response_format);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
$response = curl_exec($ch);
curl_close($ch);

But when I print type of result I am seeing string(i get file with string format).

How can a resolve this problem?

Thank's


you i think need to also include following option.

CURLOPT_ENCODING

it deals with the contents of the "Accept-Encoding: " header. This enables decoding of the response. Supported encodings are "identity", "deflate", and "gzip".

p.s : start accepting answers or stop asking questions. maybe u also need to know this

ALSO check out this link and try using the patch.

0

精彩评论

暂无评论...
验证码 换一张
取 消