This article is to share with you about how PHP upload files to seven cattle method code, the content is very detailed, next we will look at the specific content, hope can help everyone.
The simplest way to upload a file to seven KN is to use the Seven Bull official latest SDK
Installing the PHP SDK
Composer require QINIU/PHP-SDK
Upload files to seven kn
Use Qiniu\auth;use qiniu\storage\uploadmanager; $cfg = [ ' Access ' = ' your_access_key ', ' secret ' = ' YOUR ' _secret_key ', ' bucket ' = ' your_bucket ', ' domain ' = ' https://images.your_domain.com ']; $auth = new Auth ($cfg [' Access '], $cfg [' secret ']);//create a temporary upload token with an expiration time of 1 hours $token = $auth->uploadtoken ($cfg [' bucket '], NULL, 3600); $ FilePath = "./illustration.png"; $uploadMgr = new UploadManager (); list ($ret, $err) = $uploadMgr->putfile ($token, NULL , $filePath), if ($err!== null) { $this->err = $err;} else { echo $cfg [' domain ']. '/' . $ret [' key '];}
Get!