if (IS_POST) {
//图片上传设置
$setting = C('UPLOAD');
//$this->uploader = new Upload($setting,'Sae');// 实例化上传类
$upload = new \Think\Upload($setting,'Sae');// 实例化上传类
$images = $upload->upload();
//判断是否有图
if($images){
$info=$images['Filedata']['savepath'].$images['Filedata']['savename'];
//p($images);die;
if($_POST['thumb']=='image'){
$image = new \Think\Image();
//$stor = new \SaeStorage();
//$file_url = $stor->getUrl("domain",$info);
$url=$images['Filedata']['url'];
$img_name=str_replace(".jpg","_",$url);
$name=$img_name.'thumb.jpg';
$infos['image']=$info;
//p($name);die;
$image->open($url);// 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
if($image->thumb(50, 50)->save($name)){
$infos['thumb']=$name;
}
p($infos);die;
echo json_encode($infos);
}else{
echo $info;//返回文件地址和名给JS作回调用
}
}
else{
//$this->error($upload->getError());//获取失败信息
}
} 最佳答案