The first step is to have an account and Access your Access Key, Secret Key, and bucket
Access Key and Secret Key
Bucket: the created space name
Download the SDK Composer
composer require qiniu/php-sdk
Copy the code
In the code
The introduction of class
Use Qiniu\Auth; Use Qiniu\Storage\UploadManager;Copy the code
upload
$accessKey ="your accessKey"; $secretKey = "your secretKey" $bucket = "your bucket name"; $auth = new auth ($accessKey, $secretKey); $Token = $auth->uploadToken($bucket); $filePath = './php-logo.png'; $key = 'my-php-logo.png'; // Initialize the UploadManager object and upload the file. $uploadMgr = new UploadManager(); UploadManager putFile UploadManager putFile UploadManager putFile UploadManager list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); echo "\n====> putFile result: \n"; If ($err! == null) { var_dump($err); } else { var_dump($ret); }Copy the code