What are precautions for php to upload images to https servers through curl. Seeking for training
Get
Require_once '../wechat/class/configWX. php ';
Error_reporting (E_ALL );
// Upload images
$ File = dirname (_ FILE _). '\ zzz.jpg'; // file to be uploaded
$ Ch = curl_init ();
$ Url = 'https: // api.weixin.qq.com/merchant/common/upload_img? Access_token='.w._session='access_token'{.'&filename=zzz.jpg ';
Echo $ url;
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ file );
$ Data = curl_exec ($ ch); // execute curl
Echo $ data .'
';
Curl_close ($ ch );
Reply to discussion (solution)
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, "file = @ $ file ");
The title description is incorrect. The image is uploaded over https.
The parameter I passed is incorrect. it should be $ data = file_get_contents ('URL'); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data). this is passed, so it is not the same as normal.