Development, using the following method to save the file is unable to save use the method below the file has been generated, unable to save the file, Cainiao one, hope to help answer.
Function savePic ($ serverId, $ picName ){
$ AccessToken = $ this-> getAccessToken ();
$ TargetName = './upload/'.w.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 that files cannot be saved?
What does it mean that files cannot be saved?
The file is created successfully. after the method is executed, the file size is still 0 KB.
Comment out curl_setopt ($ ch, CURLOPT_FILE, $ fp );
$ S = curl_exec ($ ch );
Check the length of $ s
I suspect that Reading failed.
Comment out curl_setopt ($ ch, CURLOPT_FILE, $ fp );
$ S = curl_exec ($ ch );
Check the length of $ s
I suspect that Reading failed.
The read length using strlen is 69416. Is there a problem with the curl I wrote?
Look at this.
Curl_setopt ($ ch, CURLOPT_FILE, $ fp );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_exec ($ ch );
Look at this.
Curl_setopt ($ ch, CURLOPT_FILE, $ fp );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_exec ($ ch );
Okay, thank you,