newprog
newprog

Reputation:

download gzip file via php cURL

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"=>  $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

Upvotes: 0

Views: 1522

Answers (1)

ayush
ayush

Reputation: 14578

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.

Upvotes: 1

Related Questions