前端上传图片不列举了,主要说下后端遇到的问题:
1,一直报错, "errcode": 47001,后来看了下社区,其实应该是改下content type,代码如下:
$url = "https://api.weixin.qq.com/wxa/img_sec_check?access_token=".$accessTocken;
$post_data = array("media"=>"@".$upload_path_origin.$name);
$headers = array("Content-type: application/octet-stream");// 这里很重要!!!
$post_json_data = json_encode($post_data);
// echo $post_json_data;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json_data);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
$output = curl_exec($ch);
curl_close($ch);
echo $output;