【发布时间】:2011-01-19 07:40:59
【问题描述】:
我想下载文件并保存。 我正在使用此代码下载 gzip 文件。
$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);
但是当我打印结果类型时,我看到的是字符串(我得到的是字符串格式的文件)。
如何解决这个问题?
谢谢
【问题讨论】:
-
一个与我的问题相关的注释:当我打印 ($info = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);) 我看到 image/svg+xml.@ goreSplatter 时,我忘了说你我 2投票给你我为你的评论(我知道你喜欢它:))