Home >Backend Development >PHP Tutorial >微信开发,使用下头方法保存文件是无法保存

微信开发,使用下头方法保存文件是无法保存

WBOY
WBOYOriginal
2016-06-13 12:24:381008browse

微信开发,使用下面方法保存文件是无法保存
使用下面方法 文件已生成,无法保存文件,菜鸟一只,希望帮忙解答下。
function savePic($serverId,$picName){
$accessToken = $this->getAccessToken();
$targetName = './upload/'.$picName.'.jpg';
$ch = curl_init("http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=$accessToken&media_id=$serverId");
$fp = fopen($targetName, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
------解决思路----------------------
你这样看看
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn