Jinshan cloud PHP version S3

Source: Internet
Author: User

This is the development of file upload on Kingsoft cloud web page.Code

The accesskey and scecert of Kingsoft cloud must be used.

I uploaded 5g files successfully. Haha

As a PHP Web Page

In addition, you can directly write a blog and upload it.

<? PHP # $ access_id is your accessid # $ access_key is your accesssecretkey # $ key is upload filename # $ bucket_name is your bucketname # $ host is server address # $ URL is $ host/$ bucketname # $ policy is the rule you make for MERs # $ policy has success_action_redirect to allow your redirect your address # $ sign is credentials # policy must include expiration and condition key, condition bucket # form item ex Cept "kssaccesskeyid", "signature", "file", "policy", "Bucket", "key ", # Must be include in the Policy $ access_id = 'your access id'; $ access_key = "your secret key"; $ key = 'Your file name prefix '; $ bucket_name = "Your bucketname"; $ host = "http://kss.ksyun.com/"; $ url = $ host. $ bucket_name; function iso8601 ($ time = false) {if ($ time = false) $ time = Time (); $ date = Date ('Y-m-d \ th: I: S \. z', $ time); Return (Substr ($ date, 0, strlen ($ date)-2 ). 'Z');} function def_policy () {Global $ key; global $ redirect; $ t = time () + (3600*24 ); $ exp = iso8601 ($ T); $ policy = "{\" Expiration \ ": \" $ exp \ ", \" conditions \": [{\ "Bucket \": \ "your bucket name \"}, [\ "starts-with \", \ "\ $ key \", \ "$ key \"], {\ "success_action_redirect \": \ "$ redirect \"}, [\ "EQ \", \ "\ $ Content-Type \", \ "text/html \"]} "; return $ policy;} function cal_sign ($ Policy) {GL Obal $ access_key; $ Sign = base64_encode (hash_hmac ('sha1', $ policy, $ access_key, true); return $ sign ;}; $ policy = def_policy (); $ policy = base64_encode ($ policy); $ Sign = cal_sign ($ policy);?> <HTML> 
   Entry:  upload blog form # file: <input type = "file" name = "file"/> <br/> # <input type = "Submit" name = "Submit" value = "upload to KSS S3 "/> upload the file in the form of your blog post goes here.  

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.