收藏
回答

小程序cgi-bin/media/upload接口报错41005错误码什么回事的呢?

errcode":41005,"errmsg":"media data missing hint: [05443954] rid: 65a101b0-53920c02-56542908"


$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=".$ACCESS_TOKEN."&type=image";
if(class_exists('\CURLFile')){
    $real_path = "D:\www_pro\WWW\winfully_cn_svn\public\balance.png";
    $data = array(
        "access_token" => $ACCESS_TOKEN,
        "media" => new \CURLFile($real_path),
     );
}else{
    echo "环境比较低无法上传";
    exit();
}
$result = $this->request_post($url,helper::jsonEncode($data));
halt($result);


private function request_post($url = '', $data = ''){
    $ch  = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $res  = curl_exec($ch);
    curl_close($ch);
    return $res;
 }


回答关注问题邀请回答
收藏

2 个回答

  • Lee soo
    Lee soo
    01-12
    参数media formdata,图片不超过2M,PNG\JPEG\JPG\GIF格式
    

    01-12
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    01-12

    media没传对位置,微信没拿到。可惜我不会php

    01-12
    有用
    回复 2
    • 燚
      08-13
      大佬,我是java的也是一直拿不到,是什么原因
      08-13
      回复
    • Mr.Zhao
      Mr.Zhao
      发表于移动端
      08-14回复
      代码没写对呗,还能是啥原因,代码也不亮出来
      08-14
      回复
登录 后发表内容