pear2007

pear2007

这家伙有点懒,还没写个性签名!

  • 财富值4855
  • 威望值70
  • 总积分6535

个人信息

  • 建议你先研究这个官方的
    https://www.yiichina.com/doc/guide/2.0/input-file-upload
    然后再去找其他的
    希望你少走弯路

  • 2020-05-28 已签到
    连续签到1天,获得了5个金钱
  • 2020-05-19 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-26 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-22 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-15 已签到
    连续签到1天,获得了5个金钱
  • 2020-04-01 已签到
    连续签到2天,获得了10个金钱
  • 2020-03-31 已签到
    连续签到1天,获得了5个金钱
  • 2020-03-04 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的评论

    按照上面做的,一直报401,Your request was made with invalid credentials

    可以参考下

    public function behaviors(){
        $behaviors = parent::behaviors();
        $auth = $behaviors['authenticator'];
        unset($behaviors['authenticator']);
        // add CORS filter
        $behaviors['corsFilter'] = [
            'class' => \yii\filters\Cors::class,
            'cors' => [
                // restrict access to
                'Origin' => ['*'],
                'Access-Control-Request-Method' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'],
                'Access-Control-Request-Headers' => ['*'],
    //                'Access-Control-Allow-Credentials' => true,
                // Allow OPTIONS caching
                'Access-Control-Max-Age' => 3600,
                // Allow the X-Pagination-Current-Page header to be exposed to the browser.
                'Access-Control-Expose-Headers' => ['x-pagination-current-page','x-pagination-page-count','x-pagination-per-page','x-pagination-total-count','link'],
            ],
        ];
    
        // re-add authentication filter
        $behaviors['authenticator'] = $auth;
        // avoid authentication on CORS-pre-flight requests (HTTP OPTIONS method)
        $behaviors['authenticator']['except'] = ['options'];
    
        if (Yii::$app->getRequest()->getMethod() !== 'OPTIONS') {
            $behaviors['authenticator'] = [
                'class' =>  HttpBearerAuth::class,
            ];
        }
    
    
        return $behaviors;
    }
    
副总裁 等级规则
6535/10000
资料完整度
20/100
用户活跃度
0/100

Ta的关注

11

Ta的粉丝

13

Ta的访客

51