Home  >  Article  >  php教程  >  Sae平台的上传图片写法

Sae平台的上传图片写法

WBOY
WBOYOriginal
2016-06-07 11:38:54988browse

用thinkphp3.2.3的liaray中的Think文件下面的upload.class.php的实现,网上百度搜出来的真的是五花八门,各种各样,自己实践总结出来上传图片基于thinkphp3.2.3正确写法
if (!empty($_FILES)) {<br>                 if($_FILES['img']['size']>2*1024*1024){ <br>                     $this->error("上传图片大小不能大于2M");<br>                 }<br>                 $config=array(<br>                     'exts'=>array('jpg','gif','png'),<br>                     'rootPath'=>'./public/', //sae上的domain<br>                     'savePath'=>'upload/', //sae会自动创建<br>                     'saveRule'=>'time',<br>                 );<br>                 $upload = new \Think\Upload($config,'Sae');  //sae一定要写<br>                 $upload->thumb=false;<br>                 if (!$info=$upload->upload()) {<br>                     echo $upload->getError();die;<br>                     $this->error($upload->getError());<br>                 } else {<br>                     $_POST['img']=$info['img']['url'];<br>                 }<br>                 if(M("work")->add($_POST)){ <br>                     $this->success("提交成功",U('Index/work'));<br>                 }else{ <br>                     $this->error("提交失败");<br>                 }<br>             }

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