How PHP uploads files to seven KN method code

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.