早睡早起,方能养生
Sleep early rise early, way to keep healthy

PHP Class 'Qiniu\Storage\UploadManager' not found 引入七牛云之后提示未找到

2023-01-12 23:09
views 1074

composer require qiniu/php-sdk

 

ThinkPHP6.0引入之后

 

PHP报错:

 

Class 'Qiniu\Storage\UploadManager' not found

 

 

解决方式:

 

public function test()
{
	$accessKey = '';
	$secretKey = '';

	$uploadMgr = new UploadManager();
	$auth = new Auth($accessKey, $secretKey);
	$bucket = 'xxx-xxx-xxx';
	$token = $auth->uploadToken($bucket);
	$res = $uploadMgr->putFile($token, '2.png', './uploads/1/2.png');
	print_r($res);
}

 

修改为:

 

public function test()
{
	// 加这一句
	include_once '../vendor/qiniu/php-sdk/autoload.php';

	$accessKey = '';
	$secretKey = '';

	$uploadMgr = new UploadManager();
	$auth = new Auth($accessKey, $secretKey);
	$bucket = 'xxx-xxx-xxx';
	$token = $auth->uploadToken($bucket);
	$res = $uploadMgr->putFile($token, '2.png', './uploads/1/2.png');
	print_r($res);
}

 



分享
0 条讨论
top