Example of using seven cow cloud storage for thinkphp development (graphic)

Source: Internet
Author: User
This article is the thinkphp Development series of articles on the use of seven cow cloud storage methods and specific examples, very simple, the need for small partners can refer to the following


thinkphp Development-Use seven cow cloud storage

Seven Qiniu storage is thinkphp storage type can be one of the options, how to use it, well, not suspense, the following details how to use
First, register a seven-cow account.



thinkphp Development-Use seven cow cloud storage

Then log in



thinkphp Development-Use seven cow cloud storage

Then select Add Resource, select Object storage


thinkphp Development-Use seven cow cloud storage


thinkphp Development-Use seven cow cloud storage

Then fill in the space name (that is, bucket, the name will be used later), access control for the public (choose public access is for the convenience of operation, of course, you can also choose private, but the request resources need authorization), confirm the creation.

Enter the resource you just created to record the domain name


thinkphp Development-Use seven cow cloud storage

Select Key Management in the personal panel here you can get your accesskey and Secrekey. The preparation is done, the following is the specific configuration and code implementation.
In the configuration file config.php, do the following configuration


' Config_qiniu ' = = Array (' accessKey ' = ' = ',//Here fill seven ak ' secretkey ' = ', '//Here fill seven kn ' domain ' = ',// Here is the domain name ' bucket ' = ' sangaolamu '//Here is the "space" of seven cows, ' config ' = = Array (' maxSize ' + 5*1024*1024, ' rootpath ' and ' = '). Uploads/', ' savepath ' = ', ' savename ' = = Array (' uniqid ', '), ' exts ' = = Array (' jpg ', ' gif ', ' PNG ', ' jpeg '), ' Autosub ' = = True, ' subname ' = = Array (' Date ', ' YMD '),///And then change the original upload to the local code snippet where it needs to be uploaded to the following code $config = C (' config '); $ Config_qiniu = C (' Config_qiniu '); $upload = new Thinkupload ($config, ' Qiniu ', $config _qiniu); $info = $upload->upload ( );! [Thinkphp's seven Qiniu storage] (http://upload-images.jianshu.io/upload_images/2825702-adf11ef0707f8407?imageMogr2/auto-orient/strip% 7cimageview2/2/w/1240)

The $info is the information returned after the upload, where the URL is the address of the file, such as [url] = http://ob9pbn9dt.bkt.clouddn.com/20160802_ 57a05d764e1f4.jpg, save the field, and access this address when you access it later. This file is uploaded to the seven Cow cloud storage, and I'll give you an example of how to delete and other operations.

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.