search
Homephp教程php手册TP3.2使用UPYUN第三方存储

封装UPYUN到TP,一个小的教程,相信很多朋友会用到,给大家分享一下
1.导入UPYUN类放到Vendor中,可以去UPYUN官网下载UPYUN类:
TP3.2使用UPYUN第三方存储
2.在UpyunUpload中加入你的BUCKET,如下private $option=array(<br>         'bucket'=>'你的空间名',/// 空间名<br>         'expiration'=> '',/// 授权过期时间<br>         'save-key'=>'/upload/{random}{.suffix}',/// 文件名生成格式,请参阅 API 文档<br>         'allow-file-type'=>'jpg,jpeg,gif,png',/// 控制文件上传的类型,可选<br>         'content-length-range'=>'0,1024000',///限制文件大小,可选 默认1M<br>         'image-width-range'=>'100,1024000',///限制文件宽度<br>         'image-height-range'=>'100,1024000',///限制文件高度<br>         //'return-url'=>'agent.html',//; /// 页面跳转型回调地址 !!! iframe 回调地址,注意客户网站上要部署 agent.html 进行跨域代理<br>         //'notify-url'=>'',<br>     );3.做完上面两步,现在我们去控制器里调用我们的UPYUN了
[b][/b] public function index(){<br>             vendor('Upyun.UpyunUpload');//实例化UPyun<br>             $option=array();<br>             //$option['bucket']='think-img-test';<br>             $option['expiration']=time()+3600;<br>           //<br>             $UpyunUpload=new \UpyunUpload($option);<br>             $this->assign('updata',$UpyunUpload->getData());<br>         $this->display();<br>     }4.由于我是使用UPLOADFIY插件,所以这里我就把我index.html的代码贴给大家了:nbsp;html><br> <br> <br> <meta> <br>   <script></script><br>     <script></script><br>     <link> <br> <br> <br>     <br>     <label>banner图</label><br><br>     <input><br>     <div></div> <br> <script><br /> $(function() {<br /> $(&#039;#file_upload3&#039;).uploadify({<br /> &#039;formData&#039; : {<br /> "policy":"<{$updata.policy}>",<br /> "signature":"<{$updata.sign}>",<br /> },<br /> &#039;fileSizeLimit&#039;:1024*1024,<br /> &#039;buttonText&#039;:&#039;请上传图片&#039;,<br /> &#039;swf&#039; : &#039;__PUBLIC__/Home/swf/uploadify.swf&#039;,<br /> &#039;uploader&#039; : &#039;http://v0.api.upyun.com/<{$updata.bucket}>/&#039;,<br /> &#039;onUploadSuccess&#039;:function(file,data,response){<br /> var result=eval(&#039;(&#039; + data + &#039;)&#039;);//将字符串当成JSON解析<br /> console.log(result);<br /> if(result.code==200){//这里请求成功之后UPYUN会返回给我们一个状态码,成功是200;<br /> //do something <br /> <br /> }<br /> }<br /> });<br /> });<br /> </script><br> <br> 5.到了这里已经是成功了的,我给大家截一下我成功的图:
TP3.2使用UPYUN第三方存储
6.成功啦!哈哈!你是不是很开森。。。。。

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.