新浪云sae上传图片并生成缩略图

//有上传时
        if($_FILES['uploadfile']['name']) {
            $targetFolder=  './public/Bigfiles/';//原图地址
            $targetFolder_s=  './public/Smallfiles/';//缩略图地址
            import('ORG.Net.UploadFile');
            $upload= new UploadFile();// 实例化上传类
            $upload->maxSize  = 3145728 ;// 设置附件上传大小
            $upload->allowExts  =array('jpg', 'gif','png', 'jpeg');// 设置附件上传类型
            $upload->savePath = $targetFolder;// 设置附件上传目录
            //$this->returnSucess($_FILES);
            if(!$upload->upload()) {// 上传错误提示错误信息
 
                $this->returnError("910",$upload->getErrorMsg());
            }else{// 上传成功 获取上传文件信息
                $photo=  $upload->getUploadFileInfo();
            }
            //生成缩略图
 
            $s = new SaeStorage();
            $f = new SaeFetchurl();
           $img= new SaeImage();
            $first_img_name= $photo[0]['savename'];
            $first_img_pic= "http://xxxx-public.stor.sinaapp.com/Bigfiles/".$first_img_name;
            $first_img_file= $first_img_name;
            $img_data= $f->fetch( $first_img_pic);
            $img->setData($img_data );
            $img->resize(60);// 等比缩放
            $Smallimg= $img->exec(); // 执行处理并返回处理后的二进制数据
            $s->write('public',"Smallfiles/".$first_img_file,$Smallimg, -1);
 
 
            //返回值
            $response= new VEditHeadurlRsp();
            $response->headurl =$photo[0]['savename'];
            $response->headindex =$request->headindex;
            $this->returnSucess($response);
        }else{
            $this->returnError("911"," no file");
        }


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值