//有上传时
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");
}
新浪云sae上传图片并生成缩略图
最新推荐文章于 2021-03-12 09:50:09 发布