src/Message/Traits/Multimedia.php
public static function uploadMedia($username, $file)
    {
        if (!is_file($file)) {
            return false;
        }

        $url = vbot('config')['server.uri.file'].'/webwxuploadmedia?f=json';

        static::$file = $file;
        list($mime, $mediaType) = static::getMediaType($file);

        $data = [
            'id'                 => 'WU_FILE_0',
            'name'               => basename($file),
            'type'               => $mime,
            'lastModifieDate'    => gmdate('D M d Y H:i:s TO', filemtime($file)).' (CST)',
            'size'               => filesize($file),
            'mediatype'          => $mediaType,
            'uploadmediarequest' => json_encode([
                'BaseRequest'   => vbot('config')['server.baseRequest'],
                'ClientMediaId' => time(),
                'TotalLen'      => filesize($file),
                'StartPos'      => 0,
                'DataLen'       => filesize($file),
                'MediaType'     => 4,
                'UploadType'    => 2,
                'FromUserName'  => vbot('myself')->username,
                'ToUserName'    => $username,
                'FileMd5'       => md5_file($file),
            ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
            'webwx_data_ticket' => static::getTicket(),
            'pass_ticket'       => vbot('config')['server.passTicket'],
            'filename'          => fopen($file, 'r'),
        ];

        $data = static::dataToMultipart($data);

        $result = vbot('http')->request($url, 'post', [
            'multipart' => $data,
        ]);
        $result = json_decode($result, true);

        return ApiExceptionHandler::handle($result);
    }
public static function uploadMedia($username, $file)
    {
        if (!is_file($file)) {
            return false;
        }

        $url = vbot('config')['server.uri.file'].'/webwxuploadmedia?f=json';

        static::$file = $file;
        list($mime, $mediaType) = static::getMediaType($file);

        $data = [
            'id'                 => 'WU_FILE_0',
            'name'               => basename($file),
            'type'               => $mime,
            'lastModifieDate'    => gmdate('D M d Y H:i:s TO', filemtime($file)).' (CST)',
            'size'               => filesize($file),
            'mediatype'          => $mediaType,
            'uploadmediarequest' => json_encode([
                'BaseRequest'   => vbot('config')['server.baseRequest'],
                'ClientMediaId' => time(),
                'TotalLen'      => filesize($file),
                'StartPos'      => 0,
                'DataLen'       => filesize($file),
                'MediaType'     => 4,
                'UploadType'    => 2,
                'FromUserName'  => vbot('myself')->username,
                'ToUserName'    => $username,
                'FileMd5'       => md5_file($file),
            ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
            'webwx_data_ticket' => static::getTicket(),
            'pass_ticket'       => vbot('config')['server.passTicket'],
            'filename'          => fopen($file, 'r'),
        ];

        $data = static::dataToMultipart($data);

        $result = vbot('http')->request($url, 'post', [
            'multipart' => $data,
        ]);
        $result = json_decode($result, true);

        return ApiExceptionHandler::handle($result);
    }
@param $username
@param $file

@return bool|mixed|string