dodgepudding / wechat-php-sdk

微信公众平台php开发包, weixin developer SDK.
4.44k stars 2.32k forks source link

上传素材一直报media data missing #299

Open qidongyou opened 8 years ago

qidongyou commented 8 years ago

` $IMG = $_SERVER['DOCUMENT_ROOT'] . '/assets/images/a.png';

    $fileData = ['media' => "@". $IMG ];

    $access_token = $this->getAccessToken();

    // $fileData =json_encode($fileData, JSON_UNESCAPED_UNICODE);

    var_dump($fileData);

    set_time_limit(0);
    $url = 'https://qyapi.weixin.qq.com/cgi-bin/material/add_material?agentid=AGENTID&type=image&access_token='. $access_token;

    $res = http_post($url, $fileData);

    var_dump($res);

`

cheeman commented 7 years ago

PHP5.6要curl_setopt ($ch, CURLOPT_SAFE_UPLOAD, false);

cheeman commented 7 years ago

或者用CURLFile代替@路径