thinkphp3.2.3 在SAE上怎么对Storage里的图片进行缩略图操作

浏览:797 发布日期:2015/05/14 分类:求助交流
public function upload($thumb = True){

$rootPath = './Public/Uploads/'; // 自定义设置本地附件上传根目录
$SAErootPath='http://appwxvote20152-public.stor.sinaapp.com/Uploads/';//SAE上传目录
$thumbWidth ='140';
$thumbHeight ='190';
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 5145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = $rootPath;// 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
//$upload->saveName = array('date','Y-m-d');
$upload->autoSub = false;//自动使用子目录保存上传文件 默认为true
$upload->subName = array('date','Ymd');//子目录创建方式,采用数组或者字符串方式定义

// 上传文件
$info = $upload->upload();



if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功
//$this->success('上传成功!');
if($thumb){
foreach($info as $file){
$file_path_save=$rootPath.$file['savePath'].$file['savename'];
$file_path=$SAErootPath.$file['savename'];

$stor = new SaeStorage();
$file_url = $stor->getUrl("domain",$file['savename']);

echo $file_path_save.'&&&&&'.$file_path.'GGGGG'.$stor;
exit;
$image = new \Think\Image();
$image->open($file_path);
//$image->crop(30, 40)->save($file_path);
$image->thumb($thumbWidth,$thumbHeight,\Think\Image::IMAGE_THUMB_CENTER)->save($file_path_save);
return $file['savePath'].$file['savename'];
}
}else{
foreach($info as $file){
return $file['savePath'].$file['savename'];
}
}
}
}




返回的结果是
最佳答案
评论( 相关
后面还有条评论,点击查看>>