Use the following method file has been generated, unable to save the file, rookie one, hoping to help answer the next.
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);
}
Reply to discussion (solution)
What does it mean to be unable to save a file?
What does it mean to be unable to save a file?
File new success, after the method has finished the file size or 0kb
Comment out curl_setopt ($ch, Curlopt_file, $fp);
$s = curl_exec ($ch);
Check the length of the $s
I suspect the reading failed.
Comment out curl_setopt ($ch, Curlopt_file, $fp);
$s = curl_exec ($ch);
Check the length of the $s
I suspect the reading failed.
Read length with strlen is 69416, is not I write curl has a problem
You look like this.
curl_setopt ($ch, Curlopt_file, $fp);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, true);
Curl_exec ($ch);
You look like this.
curl_setopt ($ch, Curlopt_file, $fp);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, true);
Curl_exec ($ch);
All right, thanks.