0

phpSDK最新版uploadToken加了key出错

require_once "qiniuSDK/autoload.php";
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;

$accessKey = 'Access_Key ';
$secretKey = 'Secret_Key ';

$auth = new Auth($accessKey, $secretKey);

$bucket = 'image';
$key=$_GET['type'];

$policy = array(
    'returnUrl' => 'http://127.0.0.1:808/qiniu/fileinfo.php',
    'mimeLimit'=>'image/*',//限制上传格式
);
$token = $auth->uploadToken($bucket,$key, 3600, $policy);
//$token = $auth->uploadToken($bucket,null, 3600, $policy);这样就可以执行
$uploadMgr = new UploadManager();

报错:127.0.0.1:808/qiniu/fileinfo.php?code=403&error=key+doesn%27t+match+with+scope
请问这要怎么解决?

查看全部 2 个回答

0

你好,问你个问题,我生成token上传成功了,可是过了一个小时不能上传了,返回403, 然后我重新生成token,还是不行,不能上传,怎么回事?

推荐答案

0

已采纳

找到问题了,原来是form表单里忘记加key了。uploadToken要带key值表单中就一定要有<input name='key' value=''>