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.