您的位置:首页 > 其它

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

2014-03-03 15:40 232 查看
//有上传时
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");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  新浪云 缩略图